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.5.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.5.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.5.0
File Size Uploaded
lingya_agents_sdk-0.5.0.tar.gz 78.5 kB Details

Built distribution (wheel)

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

Total release size: 475.9 kB

Release files / lingya_agents_sdk-0.5.0.tar.gz

Download URL lingya_agents_sdk-0.5.0.tar.gz
Size 78.5 kB
Tags Source
SHA-256 checksum
How to use checksums
9f4fb22d1922d659ab832b0a9873ccde5154da912e164a43c26db8572feecbf4
BLAKE2b-256 checksum
How to use checksums
cf8b9592f53946be5509d882b71e315867c3fb70ba101e2fcf4696792c65c6e4
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 27, 2026.

Transparency log

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

Download URL lingya_agents_sdk-0.5.0-py3-none-any.whl
Size 397.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
111be309a7284234a0a1adc9e6ee5aa4bbff0668f0e28d8a0411bb2f65070d50
BLAKE2b-256 checksum
How to use checksums
bd1aab7d51eea06f3acc1f312d6f5a02be4f5edd613d3f3d35896d9593eab09f
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 27, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

0.5.0 This release

2 release files

0.4.0

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