Skip to main content

Asterisk AI Agent Gateway — Python SDK

Realtime protocol v1 client. Exchanges your API key for a five-minute token, registers the agent slug, heartbeats, reconnects with a fresh token, and hides the 16-byte binary audio envelope.

pip install ./sdks/python
import asyncio, os
from asterisk_ai_gateway import GatewayClient

client = GatewayClient(
    gateway_url=os.environ["GATEWAY_URL"],
    api_key=os.environ["GATEWAY_API_KEY"],   # keep in a secret store
    agent_slug="support-agent",
)

async def on_event(event):
    if event["type"] == "call.started":
        await client.send_dtmf(event["call_id"], "1")   # needs calls:dtmf

async def on_audio(call_id, pcm):        # PCM s16le, 16 kHz, mono
    await client.send_audio(call_id, pcm)

asyncio.run(client.run(on_event=on_event, on_audio=on_audio))

Run one client per agent_slug: the gateway accepts a single live connection per slug and answers a second one with agent-in-use.

AuthenticationError ends the stream and is never retried — the key is revoked, expired, or its partner app is disabled. Every other transport failure reconnects with exponential backoff up to max_backoff.

See examples/echo_agent.py and docs/partner/integration-guide.html.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

asterisk_ai_agent_gateway_sdk-0.1.0.tar.gz (6.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

asterisk_ai_agent_gateway_sdk-0.1.0-py3-none-any.whl (7.8 kB view details)

Uploaded Python 3

File details

Details for the file asterisk_ai_agent_gateway_sdk-0.1.0.tar.gz.

File metadata

File hashes

Hashes for asterisk_ai_agent_gateway_sdk-0.1.0.tar.gz
Algorithm Hash digest
SHA256 8679992a4084a478c2178f236193a27388c2259eaf58db611598691d3c504655
MD5 ed6e7930bca9d7d0cdc5b07bd41982d6
BLAKE2b-256 3ea3a3671c7dbde923b259578cb24637fb3414bc576f9ced0a463872f566d324

See more details on using hashes here.

File details

Details for the file asterisk_ai_agent_gateway_sdk-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for asterisk_ai_agent_gateway_sdk-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 1d3be28093ffda36867ddf2d5c3d25ffdfa463be8931a5ee6ac0ff2cee12073b
MD5 14439b7166c10c1f68d3b2c81a524316
BLAKE2b-256 c099e8e06b782ce91fc0080a0c29e7930017f7bc045380e378d9c2e41a607ce5

See more details on using hashes here.

Release history Release notifications | RSS feed

0.3.0

2 files

0.2.1

2 files

0.2.0

2 files

This release

0.1.0 This release

2 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