Skip to main content

jambonz Python SDK

Python SDK for the jambonz CPaaS platform.

Installation

pip install jambonz-python-sdk

Quick Start

Webhook (HTTP)

from aiohttp import web
from jambonz_sdk.webhook import WebhookResponse

async def handle_incoming(request: web.Request) -> web.Response:
    jambonz = WebhookResponse()
    jambonz.say(text="Hello!").gather(
        input=["speech"],
        actionHook="/handle-input",
        timeout=10,
        say={"text": "Please say something."},
    ).hangup()
    return web.json_response(jambonz.to_json())

app = web.Application()
app.router.add_post("/incoming", handle_incoming)
web.run_app(app, port=3000)

Every verb method also accepts a pydantic model for full IDE autocomplete and typo-proof nested fields:

from jambonz_sdk.webhook import WebhookResponse
from jambonz_sdk.verbs import Gather, Say
from jambonz_sdk.components import Recognizer

jambonz = WebhookResponse()
jambonz.gather(Gather(
    input=["speech", "digits"],
    action_hook="/menu",
    timeout=15,
    num_digits=1,
    say=Say(text="Press 1 for sales, 2 for support"),
    recognizer=Recognizer(vendor="deepgram", language="en-US"),
)).hangup()

Dict and kwargs styles both still work and coerce automatically, so existing apps keep running unchanged. Mix and match as you like:

jambonz.gather(
    input=["speech"],
    say=Say(text="Hello"),              # model
    recognizer={"vendor": "google"},    # dict
)

Unknown fields, missing required fields, wrong types, and violated cross-field rules (e.g. numDigits combined with minDigits/maxDigits) raise pydantic.ValidationError at construction time — no more hunting silent failures after a round-trip to the jambonz server.

WebSocket

import asyncio
from jambonz_sdk.websocket import create_endpoint

async def main():
    make_service, runner = await create_endpoint(port=3000)
    svc = make_service(path="/")

    async def handle_session(session):
        session.say(text="Hello!").hangup()
        await session.send()

    svc.on("session:new", handle_session)
    await asyncio.Future()

asyncio.run(main())

REST Client

from jambonz_sdk.client import JambonzClient

async with JambonzClient(
    base_url="https://api.jambonz.us",
    account_sid="your-account-sid",
    api_key="your-api-key",
) as client:
    call_sid = await client.calls.create({
        "from": "+15085551212",
        "to": {"type": "phone", "number": "+15085551213"},
        "call_hook": "/incoming",
    })

How It Works

Spec-driven verb generation

The SDK does not hardcode verb method signatures. Instead, verb methods (.say(), .gather(), .dial(), .agent(), etc.) are auto-generated at import time from JSON Schema files — the same schemas used by the Node.js SDK and the jambonz server.

What this means:

  • When the schema adds a new property to a verb, the SDK picks it up automatically — no code change needed
  • Every method has real typed parameters (not **kwargs: Any) so IDEs show autocomplete and type hints
  • Verb synonyms (stream ↔ listen, openai_s2s → llm with vendor: "openai") are handled by the registry

Typed pydantic models

Alongside the schema-driven method signatures, the SDK ships pydantic v2 models generated from the same JSON Schemas. They live under jambonz_sdk.verbs and jambonz_sdk.components and can be passed directly to any verb method.

These models are a build artifact — produced by scripts/regen_models.py from the bundled schemas — and get checked into the repo so end users don't need codegen tools to install the SDK.

Updating the schema

# Download the pinned version from @jambonz/schema:
python scripts/sync_schema.py

# Regenerate the typed pydantic models so they match:
python scripts/regen_models.py

# Regenerate the .pyi stubs so IDE autocomplete stays in sync:
python scripts/generate_stubs.py

If a new verb was added (not just new properties), add one line to verb_registry.py:

VerbDef("new_verb", "new_verb", doc="Description.")

Features

  • All jambonz verbs: say, play, gather, dial, conference/room, transfer, enqueue/dequeue, hangup, pause, redirect, config, tag, dtmf, dub, message, alert, answer, leave, listen/stream, transcribe, openai_s2s, google_s2s, deepgram_s2s, elevenlabs_s2s, ultravox_s2s, gptlive_s2s, qwen_s2s, voicelive_s2s, s2s, llm, dialogflow, agent, sip_decline, sip_request, sip_refer
  • Fluent chainable API: .say(...).gather(...).hangup()
  • Webhook transport: WebhookResponse for HTTP apps (works with aiohttp, FastAPI, Flask, etc.)
  • WebSocket transport: create_endpoint with Session, event handling, send()/reply()
  • REST client: JambonzClient with calls, conferences, queues, mid-call control
  • Audio streaming: Bidirectional audio via AudioStream
  • Mid-call control: inject commands (mute, whisper, record, DTMF, tag)
  • TTS token streaming: send_tts_tokens() / flush_tts_tokens()
  • Agent updates: update_agent() for mid-conversation LLM changes
  • Signature verification: HMAC-SHA256 webhook signature validation
  • Env vars: Portal discovery via OPTIONS + runtime reading

Examples

See the examples/ directory:

Example Webhook WebSocket Description
hello-world webhook websocket Minimal greeting
echo webhook websocket Speech echo with gather
ivr-menu webhook — IVR menu with speech + DTMF
voice-agent webhook websocket LLM agent with tool calls
dial webhook — Outbound dial with fallback
listen-record webhook websocket Audio recording

Development

# Create venv and install
python3 -m venv .venv
source .venv/bin/activate
pip install -e ".[dev]"

# Run tests
pytest tests/unit/          # Fast unit tests
pytest tests/integration/   # Real server tests
pytest                      # All tests

# Sync schema from upstream and regenerate pydantic models + stubs
python scripts/sync_schema.py
python scripts/regen_models.py
python scripts/generate_stubs.py

License

MIT

Metadata

Release files for jambonz-python-sdk 0.4.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for jambonz-python-sdk 0.4.0
File Size Uploaded Provenance Actions
jambonz_python_sdk-0.4.0.tar.gz 146.8 kB With provenance Details for jambonz_python_sdk-0.4.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for jambonz-python-sdk 0.4.0
File Interpreter ABI Platform Actions
jambonz_python_sdk-0.4.0-py3-none-any.whl Python 3 none any Details for jambonz_python_sdk-0.4.0-py3-none-any.whl

Total release size: 428.4 kB

Release files / jambonz_python_sdk-0.4.0.tar.gz

Download URL jambonz_python_sdk-0.4.0.tar.gz
Size 146.8 kB
Tags Source
SHA-256 checksum
How to use checksums
bbb61126ae03d11247f8059813980d8e766da980c8a9c262ba878cae97ec62ae
BLAKE2b-256 checksum
How to use checksums
1e3ac2f08120511ae2b127d6e0f9bf484d436dc7e20fa4d3c44374441ab92765
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 24, 2026.

Transparency log

Release files / jambonz_python_sdk-0.4.0-py3-none-any.whl

Download URL jambonz_python_sdk-0.4.0-py3-none-any.whl
Size 281.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
52c5bd7eb7302b4d6616f7e83672e5c4587627ac450841d29bbe2ac219fd5df7
BLAKE2b-256 checksum
How to use checksums
ac7b19e5ed97cecfdfe6a0d846b14ba69bf58550be98213e85a14fc463c856db
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 24, 2026.

Transparency log

Security for jambonz-python-sdk 0.4.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.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for jambonz_python_sdk-0.4.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 24, 2026.

Transparency log

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.

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