Skip to main content

灵涯 Agents Python SDK

Lingya Agents SDK for Python

用于在 Python 可信服务端调用灵涯 Agents OpenAPI。 Use this SDK to call Lingya Agents OpenAPI from a trusted Python server.

安装

Installation

pip install lingya-agents-sdk==0.4.0

快速开始

Quick start

import os

from lingya_agents_sdk import AgentsClient, OpenApiCredentials
from lingya_agents_sdk.models.ai_chat_input import AiChatInput

client = AgentsClient(
    "https://lingtong.lingya.tech/",
    os.environ["OPENAPI_CHANNEL_ID"],
    OpenApiCredentials(
        os.environ["OPENAPI_AK"],
        os.environ["OPENAPI_SK"],
    ),
)

with client.for_user("external-user-id") as user:
    submission = user.chat.create_chat(AiChatInput(query="你好"))

channel_id 只在创建 AgentsClient 时提供,业务方法不再接收它。 Provide channel_id only when creating AgentsClient; business methods do not accept it.

SSE 事件流

SSE event stream

from lingya_agents_sdk.models.ai_chat_stream_input import AiChatStreamInput

with client.for_user("external-user-id") as user:
    for event in user.chat.stream_chat_events(
        submission.conversation_id,
        AiChatStreamInput(message_id=submission.message_id),
    ):
        print(event.type)

API 分组

API groups

可用分组为 chat、configuration、conversations、events、files、interactions、knowledge、messages、sql 和 workspace。 Available groups are chat, configuration, conversations, events, files, interactions, knowledge, messages, sql, and workspace.

错误处理

Error handling

from lingya_agents_sdk import ApiError

try:
    user.conversations.get_conversation_title("conversation-id")
except ApiError as error:
    print(error.status_code, error.response_body)

请只在可信服务端保存 secret_key,不要将其放入浏览器、移动端、桌面端或日志。 Keep secret_key on trusted servers only; never put it in browsers, mobile apps, desktop apps, or logs.

Metadata

Release files for lingya-agents-sdk 0.4.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for lingya-agents-sdk 0.4.0
File Size Uploaded
lingya_agents_sdk-0.4.0.tar.gz 68.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for lingya-agents-sdk 0.4.0
File Interpreter ABI Platform
lingya_agents_sdk-0.4.0-py3-none-any.whl Python 3 none any Details

Total release size: 324.5 kB

Release files / lingya_agents_sdk-0.4.0.tar.gz

Download URL lingya_agents_sdk-0.4.0.tar.gz
Size 68.9 kB
Tags Source
SHA-256 checksum
How to use checksums
3d2cffc1caa27fa321702b789b6d5ebfbc0540c135990a053967d0de471918fe
BLAKE2b-256 checksum
How to use checksums
36bf9b503d6f3e18f76b3230d85a3e10e74f0a21830c6ac4b0ed48283852cda2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 16, 2026.

Transparency log

Release files / lingya_agents_sdk-0.4.0-py3-none-any.whl

Download URL lingya_agents_sdk-0.4.0-py3-none-any.whl
Size 255.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
11ae4cf7e314cc2d2ca4d99b237c1814bbfe27d6e14a3fdac9e1454afcab2890
BLAKE2b-256 checksum
How to use checksums
b530b2641616102e3874c93a9f3f2729bd29a83dd4cb276fb3dcdaf96eef50c2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 16, 2026.

Transparency log

Release history Release notifications | RSS feed

0.5.0

2 release files

This release

0.4.0 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page