Tello SDK for Python — WebSocket realtime client and REST resource API client for the Tello API gateway (api-gateway)
pip install tello-ai-sdk==0.2.0 Copy PIP instructions
repo: tello-python · PyPI package: tello-ai-sdk · import: tello
Tello SDK for Python — a thin WebSocket realtime client for the API gateway (api-gateway) /sdk endpoint, plus TelloApi, a client for the public REST resource API. The WebSocket client is the "conversation brain": the gateway streams each caller turn from a live phone call, and your handler's reply is forwarded back into the call.
The realtime protocol contract lives in docs/protocol/sdk-ws.v1.md. The REST resource API (tools, agents, crews, call drafts) is in §6.
pip install tello-ai-sdk # requires Python >= 3.10; imports as `tello` 2. API key The key authenticates the connection through an application-level handshake: right after the socket opens the SDK sends an auth frame carrying the key in its token field and waits for the server's auth.ok before anything else runs. The key is never placed on the WS upgrade request or in the URL query. This is fully internal — you never call auth yourself; connect() (and async with) simply does not succeed until authentication has. Issue a key in the portal (Agent settings → Advanced → Agent-linked / SDK).
Pass it explicitly or via environment variables:
export TELLO_API_KEY="tello_live_xxx" export TELLO_URL="wss://api.telloai.io/sdk" # optional; defaults to wss://api.telloai.io/sdk TelloClient() with no arguments then reads TELLO_API_KEY / TELLO_URL. The client appends sdk=python&version= &protocol= to the URL query (other path/query parts are kept); the server only logs them.
import asyncio from tello import TelloClient, EventType async def main(): async with TelloClient(api_key="tello_live_xxx", url="wss://api.telloai.io/sdk") as client: @client.on(EventType.USER_TURN) async def on_user_turn(event): await client.answer(text="확인했습니다. 계속 말씀해주세요.") await client.create_call(to="+821012345678", prompt="예약 확인") await client.wait_closed() asyncio.run(main()) TelloClient(...) is the constructor (Python has no new). The async with form is sugar for connect() / aclose(); use them explicitly if you prefer:
client = TelloClient(api_key="tello_live_xxx", url="wss://api.telloai.io/sdk") await client.connect() client.on(EventType.USER_TURN, on_user_turn) await client.create_call(to="+821012345678", prompt="예약 확인") await client.wait_closed() await client.aclose() 4. Realtime turn events (pub/sub) Subscribe handlers (sync or async) per event type via client.on(...):
Payload fields above are the Python attribute names; the wire frames themselves use camelCase keys (sessionId, callId, turnIndex, previousStatus, failureReason, requestId). An unknown type falls back to the base Event so forward-compatible additions still reach subscribers.
Commands: await client.create_call(to, prompt="", metadata=None, request_id=None), await client.answer(text, message_id=None, request_id=None), await client.send_dtmf(digits, message_id=None, request_id=None), await client.cancel(), await client.get_summary(call_id, request_id=None). create_call always sends a requestId: the one you pass, or a generated UUID when you omit it. Give each command its own request_id, or omit it (see §5).
await client.wait_closed() resolves when the call reaches a terminal state (call.completed / call.noAnswer / call.failed, or a call.statusChanged with status cancelled) or the connection closes. After cancel(), the gateway ends the call with that cancelled call.statusChanged (its previous_status is the status before the cancel); no call.completed follows. A wait in progress returns when its own call ends, even if a handler has already started a follow-up call; call wait_closed() again to wait for the follow-up. It raises instead when the call's create_call fails (see §5); an error from any other command does not end the wait.
Gateway error frames map 1:1 to exceptions (see docs/errors/errors.v1.json):
Every error carries the gateway code on .code — branch on that, never on .args[0], which is display text the gateway may reword.
createCall can also be refused before any call exists — no call.created, no callId, no charge. The gateway never retries these; any retry policy is yours.
Command-level errors are also delivered to EventType.ERROR subscribers without closing the socket. Only an error answering the call's own create_call ends the call: create_call always sends a requestId (generated when you omit it) and the gateway echoes it on the error frame, which is how the SDK tells that error apart. Errors from answer, send_dtmf, get_summary, and cancel do not end the call; they are delivered only as EventType.ERROR events, and wait_closed() keeps waiting for the call's terminal event. So give each command its own request_id, or omit it: never reuse the create_call requestId on another command, because an error answering that command would then end the wait. wait_closed() re-raises the relevant error so a failed create_call (e.g. toRequired, callRejected) does not hang:
An EventType.ERROR handler receives an ErrorEvent, not an exception. To turn it into the typed exception from the tables above, pass its fields to exception_for from tello.errors:
from tello import CallRefusedError, EventType from tello.errors import exception_for @client.on(EventType.ERROR) def on_error(event): error = exception_for(event.code, event.message, event.question) if isinstance(error, CallRefusedError): print(f"refused: {error.code}") The gateway drives a WS-level ping heartbeat; websockets answers pongs automatically. There is no reconnect/resume — treat an abnormal close as reconnect-worthy and restart the call.
TelloApi is a separate client for the public REST API: tools, agents and crews (create, read, update, delete), agent and crew lists, crew generation from a goal, and call drafts. It needs no extra dependency (the standard library's urllib, run off the event loop). Bodies and results are plain dict[str, Any], so fields this SDK does not know yet are kept.
call_drafts.confirm places a real, billed phone call. call_drafts.create may also call at once when the agent's scenario is ready (status confirmed with a callId). Every draft status (pendingConfirmation, needsClarification, refused, confirmed) is a 201 success, not an error.
Idempotency keys are sent only when you pass idempotency_key (create, generate, draft create/revise). call_drafts.confirm always sends one: yours, or a generated UUID v4. A key must be 1–255 printable ASCII characters (0x20–0x7E) with no comma, otherwise ValueError is raised before any request; so is an empty id. generate_and_wait returns a failed job instead of raising (branch on job["status"]) and raises TimeoutError with the job id when it is still running after timeout.
An error response raises TelloApiError (a TelloError) with status (HTTP), code (the envelope's error, verbatim snake_case), message, data (dict or None) and idempotency_key (the key sent, or None). A response that is not the error envelope (a proxy page, for example) has code = "http_ "; an undocumented success status or a body that is not a JSON object has code = "invalid_response". When no response arrives (connection failure or timeout) TelloApiConnectionError is raised with idempotency_key and the cause on __cause__ — a write that fails this way may still have been applied: check with get/list before resending.
The full list is in the public REST error reference. Branch on code, never on message:
from tello import TelloApiConnectionError, TelloApiError try: call = await api.call_drafts.confirm(draft_id) except TelloApiError as e: if e.code == "draft_already_confirmed": print("already placed:", e.data["callId"]) else: raise except TelloApiConnectionError as e: # The call may have been placed: retry with the same key, never a new one. call = await api.call_drafts.confirm(draft_id, idempotency_key=e.idempotency_key) 7. Examples Runnable programs live in examples/:
uv run python examples/basic_call.py # connect, one call, answer each turn uv run python examples/agent_callback.py # full lifecycle, history, cancel, typed errors uv run python examples/call_summary.py # gated live scenario ending in call.summary They place real calls. Read examples/README.md first.
tello-ai-sdk 0.1.x and 0.2.x implement Tello WS protocol 1.0.
The full frame contract is in docs/protocol/sdk-ws.v1.md, with docs/events/sdk-events.v1.schema.json and docs/errors/errors.v1.json. Those three files are generated copies of the canonical contract that lives beside the gateway implementation — read them here, edit them there.
Both files in this release have provenance metadata.
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
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 verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 19, 2026.
Both files in this release have been uploaded with provenance metadata.
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.




