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 asterisk-ai-agent-gateway-sdk
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.2.0.tar.gz (6.9 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.2.0-py3-none-any.whl (8.2 kB view details)

Uploaded Python 3

File details

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

File metadata

File hashes

Hashes for asterisk_ai_agent_gateway_sdk-0.2.0.tar.gz
Algorithm Hash digest
SHA256 df3a21201cfc5561b2629848c06e5a5fe4236fab0c3db5d734515c5b7096cc96
MD5 ae461e403ab5eb3723890fd93ac4f3e5
BLAKE2b-256 4c55f1fab1abe440b5180867f76e0e00115fdd237d37817c841c2ad649ddeb69

See more details on using hashes here.

Provenance

The following attestation bundles were made for asterisk_ai_agent_gateway_sdk-0.2.0.tar.gz:

Publisher: release-sdks.yml on sonnt68/Asterisk-AI-Agent-Gateway

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

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

File metadata

File hashes

Hashes for asterisk_ai_agent_gateway_sdk-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 764d24faacdac114c95b998a8cf7baaf9fea2cc9332929cfebb10c0693f848af
MD5 fa5ce02b8389225c940e8427ef9eb4e3
BLAKE2b-256 ad799ebb7c691bd49d6eeaa694070fbf11c8463ada6318312393da7310a02335

See more details on using hashes here.

Provenance

The following attestation bundles were made for asterisk_ai_agent_gateway_sdk-0.2.0-py3-none-any.whl:

Publisher: release-sdks.yml on sonnt68/Asterisk-AI-Agent-Gateway

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

0.3.0

2 files

0.2.1

2 files

This release

0.2.0 This release

2 files

0.1.0

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