Skip to main content

ThunderPhone Python SDK

Python 3.10+. Install pip install thunderphone. Set THUNDERPHONE_API_KEY in your environment, or pass api_key= to ThunderPhone. Optional base_url defaults to https://api.thunderphone.com (do not append /v1).

import os
from thunderphone import ThunderPhone, AgentRequest, PlaceCallRequest

with ThunderPhone() as api:
    agent = api.agents.create(AgentRequest(
        name="Reception",
        prompt="Help callers with scheduling and business information.",
        voice=os.environ["THUNDERPHONE_VOICE"],
    ))
    call = api.calls.place(PlaceCallRequest(
        agent_id=agent.id,
        from_number=os.environ["FROM_NUMBER"],
        to_number=os.environ["TO_NUMBER"],
        idempotency_key="appointment-123",
    ))
    done = api.calls.wait_for_completion(
        call.call_id, timeout=300, poll_interval=1,
    )
    if done.status == "failed":
        raise RuntimeError(done.end_reason)
    print(api.calls.transcript(call.call_id).transcripts)

Choose a voice from GET /v1/voices. Outbound calls require an outbound-capable carrier number, sufficient balance, and the organization's outbound confirmation. Polling returns both completed and failed calls. A polling deadline raises TimeoutError; HTTP timeouts and transport errors propagate. Writes are never retried automatically. Reuse an idempotency key only for the same request.

Every operation has generated synchronous and asynchronous functions and typed request/response models under thunderphone.generated. For example:

from thunderphone.generated.api.calls import calls_list

with ThunderPhone() as api:
    page = calls_list.sync(client=api.client, limit=20, offset=0)

Generated functions offer sync, sync_detailed, asyncio, and asyncio_detailed where the operation has a response body. Detailed variants retain status and headers; undocumented errors return parsed=None unless raise_on_unexpected_status is enabled on the generated client. Helpers raise ThunderPhoneError with status and body. The client sends X-ThunderPhone-Client: sdk-python/0.3.0. Use a context manager or close() for the facade; close generated async clients with their async context manager.

Verify webhook and tool-call signatures

Every request ThunderPhone sends to your server carries X-ThunderPhone-Signature-V2, a timestamped HMAC over the method, path, query and raw body. verify_signature checks it and rejects requests older than five minutes:

from thunderphone import verify_signature

ok = verify_signature(
    request.headers.get("X-ThunderPhone-Signature-V2"),
    secret=os.environ["THUNDERPHONE_WEBHOOK_SECRET"],  # or a list while rotating
    method=request.method,
    path="/thunderphone-webhook?source=prod",  # path and query exactly as received
    body=raw_body,  # the raw bytes, before any JSON parsing
)

tolerance= changes the 300-second window. compute_signature builds a signature for your own tests. The module uses only the standard library. See Verify webhook signatures.

API reference · OpenAPI

Development: pip install -e ., python -m unittest discover -s tests -v, python -m build. Regenerate from the repository root using scripts/generate-sdks.sh; never edit thunderphone/generated/ by hand.

Metadata

Release files for thunderphone 0.3.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 thunderphone 0.3.0
File Size Uploaded Provenance Actions
thunderphone-0.3.0.tar.gz 520.2 kB With provenance Details for thunderphone-0.3.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for thunderphone 0.3.0
File Interpreter ABI Platform Actions
thunderphone-0.3.0-py3-none-any.whl Python 3 none any Details for thunderphone-0.3.0-py3-none-any.whl

Total release size: 2.0 MB

Release files / thunderphone-0.3.0.tar.gz

Download URL thunderphone-0.3.0.tar.gz
Size 520.2 kB
Tags Source
SHA-256 checksum
How to use checksums
2713f7f67cc8a4baa6e4047de4d7c996302de3c0352888fb9b84f336ccac82f8
BLAKE2b-256 checksum
How to use checksums
d789f4cac840a9b97f12c838900cb9b8f6be2b9a7d9b02e427002bcfad166741
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 Nov 6, 2026.

Transparency log

Release files / thunderphone-0.3.0-py3-none-any.whl

Download URL thunderphone-0.3.0-py3-none-any.whl
Size 1.5 MB
Tags Python 3
SHA-256 checksum
How to use checksums
b61f0e17b848408f8c7b99c551ae0dd67be34677cacdcecf7b4d3ee8c142b9b6
BLAKE2b-256 checksum
How to use checksums
3e841dda57a5c13750824c6eb68c4b07391c33ee4815d19eaffb8fe1d1d767ec
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 Nov 6, 2026.

Transparency log

Security for thunderphone 0.3.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 thunderphone-0.3.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 Nov 6, 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