End-to-end: dial an outbound number, stream the answer audio to disk, and hang up cleanly.

Hello, dial

import asyncio
from telequick.client import TeleQuickClient

async def main():
    client = TeleQuickClient(
        endpoint="quic://engine.telequick.dev:9090",
        service_account_path="/etc/telequick/service-account.json",
    )

    async with client.connect_async():
        await client.dial(
            to="sip:+15551234567@example.sip.livekit.cloud",
            trunk_id="default",
            call_from="+18005550100",
            max_duration_ms=60_000,
        )
        # Hold the connection open while the gateway works.
        await asyncio.sleep(30)

asyncio.run(main())
The async with client.connect_async(): block:
  • Opens the QUIC session (ALPN h3)
  • Auto-subscribes to CallEvents with the client’s UUID
  • Tears the session down on exit

Capturing audio

import asyncio
from telequick.client import TeleQuickClient

async def main():
    client = TeleQuickClient(
        "quic://engine.telequick.dev:9090",
        "/etc/telequick/service-account.json",
    )

    audio_out = open("incoming.alaw", "wb")

    def on_audio(payload_bytes):
        pcm = client.deserialize_audio_frame(payload_bytes)
        audio_out.write(pcm)

    def on_event(payload_bytes):
        sid, status = client.deserialize_call_event(payload_bytes)
        print(f"[event] {{sid}}{{status}}")

    client.on_audio_frame = on_audio
    client.on_call_event = on_event

    async with client.connect_async():
        await client.dial(
            to="sip:+15551234567@example.sip.livekit.cloud",
            trunk_id="default",
            call_from="+18005550100",
            max_duration_ms=120_000,
        )
        await asyncio.sleep(120)

asyncio.run(main())

Hanging up

If you tracked the call_sid in the event callback:
await client.terminate(call_sid)
For graceful shutdown of any outstanding calls when the script exits, sweep the active set:
ACTIVE = set()

def on_event(payload):
    sid, status = client.deserialize_call_event(payload)
    if status in ("COMPLETED", "FAILED", "BUSY", "NO_ANSWER"):
        ACTIVE.discard(sid)
    else:
        ACTIVE.add(sid)

# … later, on shutdown:
for sid in list(ACTIVE):
    await client.terminate(sid)

Pushing audio out

To stream TTS or pre-recorded prompts back into the call:
async for chunk in tts_stream(text="Hello, world."):
    await client.push_audio(call_sid, chunk)
Each push_audio call serializes one AudioFrame and writes it to the single outbound uni-stream the client lazily opens. Don’t open your own streams.

Next

  • Reference — every method, every argument.
  • Examples — bulk dialer, AI bot, browser bridge.