orbit-agent-chat
Python SDK for the Orbit Agent Chat API. Your AI Agent's backend uses it to hand a conversation to human support staff: create a chat, issue a short-lived token for the browser, read and post messages, and close the chat. It runs server-side because it holds an Orbit API token with the agent_chat:write scope. Never ship that token to a browser.
Requires Python 3.9+. The only dependency is httpx.
Install
pip install orbit-agent-chat
# or: uv add orbit-agent-chat
Releases (wheel and sdist) are published to PyPI from the Orbit repository's CI (tag sdk-python-vX.Y.Z). A build machine that cannot reach pypi.org can install through a PyPI mirror (pip install -i <mirror> orbit-agent-chat).
Use
from orbit_agent_chat import HistoryItem, OrbitAgentChatClient, OrbitAgentChatError
with OrbitAgentChatClient("https://support.example.com", api_token) as client:
result = client.create_chat(
title="Cannot reset my password",
description="The reset email never arrives.",
session_id="sess-123", # your Agent's session
uuid="user-uuid-456", # your Agent's end user
history=[HistoryItem("user", "I can't log in"), HistoryItem("assistant", "Let me hand you to a human")],
)
chat = result.chat # result.replayed is True when the idempotency key was seen before
token = client.issue_token(chat.id) # give token.token to the browser
page = client.list_messages(chat.id, after=0, limit=100)
client.send_message(chat.id, "One more detail: it happens on mobile")
client.close_chat(chat.id)
AsyncOrbitAgentChatClient has the same methods as coroutines; use async with or await client.aclose():
async with AsyncOrbitAgentChatClient("https://support.example.com", api_token) as client:
result = await client.create_chat(title="...", description="...", session_id="...", uuid="...")
What goes into a chat
create_chat also takes three optional arguments:
requester_email: the end user's email as your Agent knows it. Orbit staff see it on the ticket's Agent chat card; nothing is emailed to it, and the ticket's requester stays a synthetic customer of your integration either way.note: context for Orbit staff, at most 2 000 characters.payload: a JSON object for Orbit staff (for example your Agent's state), at most 65 536 bytes once serialised.
note and payload are seen by Orbit staff only, never by the end user. history (the conversation so far, shown to both) is at most 500 items and 200 000 characters of content in total.
Your own httpx client
Pass http_client=httpx.Client(...) (or httpx.AsyncClient) to control proxies and transports. A client you pass in is not closed by the SDK. The timeout argument (default 10 s) applies only to the client the SDK creates; when you pass http_client, set the timeout on that client.
Idempotency
create_chat always sends an idempotency key, in the Idempotency-Key header and the body. Pass your own idempotency_key (for example one derived from your session) to make a create safe across your own restarts; without one the SDK generates a random key and reuses it for every retry of that call. Re-sending a key with the same content returns the original chat with replayed=True; the same key with different content is a 409 agent_chat_idempotency_mismatch.
Retries
Up to max_retries (default 3) retries, waiting 0.5 s, 1 s, 2 s ... (capped at 8 s, plus or minus 20% jitter). A 429 waits for its Retry-After header, or the error body's details.retry_after when the header is missing, at most 60 s.
| Call | Retried on |
|---|---|
create_chat, issue_token, close_chat, list_messages |
network failure, 429, 502, 503, 504 |
send_message |
429 only |
Other 4xx responses and 500 are never retried. send_message is not retried after a network failure or a 5xx because the request may already have been processed, and the API has no idempotency key for messages, so a retry could post the customer's message twice. If it fails with network_error, call list_messages to see whether it landed before sending again.
Errors
Every failure raises OrbitAgentChatError with status, code, message, request_id, details and retry_after (seconds, or None). A failure to get any response (after retries) has status == 0 and code == "network_error"; a non-JSON error body gets the code http_<status>.
code |
Status | Meaning |
|---|---|---|
agent_chat_closed |
409 | The chat or its ticket is closed; no more messages |
agent_chat_not_found |
404 | Unknown chat, or it belongs to another API client |
agent_chat_idempotency_mismatch |
409 | The idempotency key was used with different content |
agent_chat_stream_limit |
429 | Too many concurrent streams for the chat |
Handing the chat to the browser
The browser must never see your API token. After create_chat, call issue_token(chat.id) on your backend and return token.token (valid 15 minutes, token.expires_at) with chat.id to the page. The browser sends it as Authorization: AgentChat <token> to read and post messages and to open the realtime stream (the @zilliz/orbit-agent-chat Node/browser package does this and renews the token). When it expires, issue another from your backend. Chat tokens cannot create chats, issue tokens or close chats.
Metadata
Release files for orbit-agent-chat 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| orbit_agent_chat-0.1.0.tar.gz | 7.4 kB | Without provenance | Details for orbit_agent_chat-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| orbit_agent_chat-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for orbit_agent_chat-0.1.0-py3-none-any.whl |
Total release size: 18.3 kB
Release files / orbit_agent_chat-0.1.0.tar.gz
| Download URL | orbit_agent_chat-0.1.0.tar.gz |
|---|---|
| Size | 7.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
ee34252f111dcbf74966e0870781e3238e366b0ecd640fc3caccde508bcec33d
|
|
BLAKE2b-256 checksum How to use checksums |
bd5d20843b47bcef77d9eef5a9e76ee52cc378d91321f187271672aff5cb7f76
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Release files / orbit_agent_chat-0.1.0-py3-none-any.whl
| Download URL | orbit_agent_chat-0.1.0-py3-none-any.whl |
|---|---|
| Size | 10.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
73036e78baf8a344754fdb35d78a48131e5815145e13c309de73c3927ba0430c
|
|
BLAKE2b-256 checksum How to use checksums |
bd6f75e90e9e4a3a8734dbf0deab7fdeb766c7d78ff3f6289db597b7d47aa37f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Security for orbit-agent-chat 0.1.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.