Skip to main content

a13n Python SDK

Call an Agent, continue a conversation, and stream its progress from Python. The Agent runs on your a13n Service; this SDK connects your application to it.

Requires Python 3.13+ and access to an a13n Service.

Quick start

1. Install this checkout

This repository contains the pre-release SDK. To try the code documented here, install from source rather than assuming the package registry has the same API:

git clone https://github.com/converge-ai-labs/a13n-sdk-python.git
cd a13n-sdk-python
uv venv --python 3.13
uv pip install .

2. Get your connection details

Ask your Service administrator, or use your Console, for:

Setting What to provide
A13N_SERVICE_URL The Service URL, without /api/v1; not the Console URL.
A13N_API_TOKEN An API key for the workspace you want to use.
A13N_AGENT The ID of an Agent configured with a working model.

Set these environment variables in your shell or secret manager. For example, in Bash:

export A13N_SERVICE_URL='https://your-service.example'
export A13N_AGENT='your-agent-id'
read -rsp 'API key: ' A13N_API_TOKEN; echo
export A13N_API_TOKEN

The API key selects the workspace for you. No workspace ID is needed for this example.

3. Send a message

Save this as quickstart.py:

import asyncio
import os
from a13n import Client, PreviewInterrupted


async def main() -> None:
    async with Client(os.environ["A13N_SERVICE_URL"], os.environ["A13N_API_TOKEN"]) as client:
        agent = client.agents(os.environ["A13N_AGENT"])
        interaction = await agent.start("Explain what you can help me with.")
        outcome = await interaction.result()
        print("Status:", outcome.status)
        print("Thread:", interaction.thread.id)

        print("Reply:", outcome.text if outcome.text is not None else outcome.output)


asyncio.run(main())

Run it with the environment you created above:

.venv/bin/python quickstart.py

For an ordinary reply, you should see Status: completed, a Thread ID, and the Agent's response. A Thread is a conversation; a Run is one execution within it. start() returns an Interaction, which lets you wait for the result or stream progress.

outcome.output preserves the full structured Run output; outcome.text is available only when it is a string, including an empty string. Neither requires an Items request. Advanced saved display is a separate, bounded ordinal window; see windowed display and recovery.

An Agent can also pause for input (waiting), fail (failed), or be cancelled (cancelled). See read and handle results for those cases. Omitting a key generates one key before dispatch, exposed as interaction.idempotency_key; the SDK never retries a mutation. Durable or cancellation-safe jobs must persist their own key and identical input/options before sending. See recovery.

Continue the conversation

Add this inside main(), while the Client is still open, after the first completed reply:

follow_up = await agent.send(
    interaction.thread.id,
    "Give me a concrete example.",
)
next_outcome = await follow_up.result()
print(next_outcome.status)

Save the Thread ID to continue later. Each call to send() selects the Agent explicitly; a conversation is not permanently tied to one Agent. Normal explicit messages also continue after failed or cancelled Runs: last_run_id names the most recently sealed Run of any outcome, whose nearest checkpoint supplies history. Those outcomes pause automatic advancement, not explicit continuation. A waiting Run instead needs explicit resume with all answers.

Stream progress

Replace the start() / result() section with this when you want updates while the Agent works:

interaction = await agent.start("Draft a short project plan.")
async with interaction:
    try:
        async for chunk in interaction.text_stream():
            print(chunk, end="", flush=True)
    except PreviewInterrupted as error:
        print("\nPreview stopped:", error.reason)
    outcome = await interaction.result()
print("Final output:", outcome.output)
print("Status:", outcome.status)

The loop ends when this execution finishes or pauses for input, even if the connection stays open. The context manager cleans up the connection if you break out early. Closing it stops local observation, not the remote Agent.

Text chunks are provisional root-assistant preview, not a lossless transcript. Gap/reset and unsupported framing stop preview without losing the authoritative result. For native progress events use async for frame in interaction instead; never consume raw and text concurrently. Streaming and results explains the limits and local lifetime.

Native Service API

For resource management and lower-level Service operations, use the generated client.api entry on the same Client:

response = await client.api.agents.list(limit=10)
for agent_view in response.value.items:
    print(agent_view.id, agent_view.name)

Replace previous client.resources.<collection> calls with client.api.<collection>; no resources alias is retained before 0.1. The authored client.agents(agent_id) conversation workflow is unchanged. See the complete resource API for typed request models and HTTP evidence, including Findings, analyses, session message authors, and explicit saved Run content reads.

Next steps

The Python SDK guide takes you from your first conversation to an application that can recover after interruptions:

For development and testing, see Contributing. The SDK specification and pinned Service source describe compatibility and implementation contracts.

Licensed under Apache-2.0.

See Execution options and migration for scoped command variables and compatibility notes.

Metadata

Release files for a13n 0.3.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 a13n 0.3.0
File Size Uploaded Provenance Actions
a13n-0.3.0.tar.gz 841.8 kB Without provenance Details for a13n-0.3.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for a13n 0.3.0
File Interpreter ABI Platform Actions
a13n-0.3.0-py3-none-any.whl Python 3 none any Details for a13n-0.3.0-py3-none-any.whl

Total release size: 2.3 MB

Release files / a13n-0.3.0.tar.gz

Download URL a13n-0.3.0.tar.gz
Size 841.8 kB
Tags Source
SHA-256 checksum
How to use checksums
8a8e5524a4ac70a627f7eab8552b892df7ae3c1ea0aa317123461e82b00739e8
BLAKE2b-256 checksum
How to use checksums
a060415b11ef40f5d44d0bd45c1619938cc3e4f2a1202ecba65553d9226ae4e1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.13.9 {"installer":{"name":"uv","version":"0.13.9","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / a13n-0.3.0-py3-none-any.whl

Download URL a13n-0.3.0-py3-none-any.whl
Size 1.5 MB
Tags Python 3
SHA-256 checksum
How to use checksums
511f6815fedf89b441af232dc5a56b335836c5bab4b58c69dfb3fff24f35175b
BLAKE2b-256 checksum
How to use checksums
76f8f941e1d0fe7dbea7014ca490d57779499edd60bed90b99b8454537d9d888
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.13.9 {"installer":{"name":"uv","version":"0.13.9","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Security for a13n 0.3.0

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.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

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