Skip to main content

gradbot

Python bindings for the gradbot voice AI library. Real-time speech-to-speech with tool calling.

Installation

pip install gradbot

Environment Variables

Variable Required Description
GRADIUM_API_KEY Yes API key for Gradium STT/TTS services
LLM_API_KEY Yes API key for OpenAI-compatible LLM
LLM_BASE_URL No LLM API base URL (defaults to OpenAI)
LLM_MODEL No LLM model name (auto-detected if only one available)
GRADIUM_BASE_URL No Base URL for Gradium services

Quick Start

import asyncio
import gradbot

async def main():
    input_handle, output_handle = await gradbot.run(
        session_config=gradbot.SessionConfig(
            voice_id="NbpkqMVS3CJeq2j8",
            instructions="You are a helpful assistant.",
            language=gradbot.Lang.En,
        ),
        input_format=gradbot.AudioFormat.OggOpus,
        output_format=gradbot.AudioFormat.OggOpus,
    )

    while True:
        msg = await output_handle.receive()
        if msg is None:
            break
        if msg.msg_type == "audio":
            play(msg.data)  # bytes
        elif msg.msg_type == "tool_call":
            result = handle(msg.tool_call.tool_name, msg.tool_call.args_json)
            await msg.tool_call_handle.send(result)

asyncio.run(main())

Remote Mode

Connect to a gradbot_server instead of running STT/LLM/TTS locally:

input_handle, output_handle = await gradbot.run(
    gradbot_url="wss://your-server.com/ws",
    gradbot_api_key="grd_...",
    session_config=config,
    input_format=gradbot.AudioFormat.OggOpus,
    output_format=gradbot.AudioFormat.OggOpus,
)

When gradbot_url is set, all other client params are ignored. The server handles everything.

FastAPI Integration

The gradbot.websocket and gradbot.routes modules provide a WebSocket handler and route setup for building voice demos.

import fastapi
import gradbot

app = fastapi.FastAPI()
cfg = gradbot.config.from_env()

gradbot.routes.setup(app, config=cfg, static_dir="static", with_voices=True)

@app.websocket("/ws")
async def ws(websocket: fastapi.WebSocket):
    await gradbot.websocket.handle_session(
        websocket,
        config=cfg,
        on_start=lambda msg: gradbot.SessionConfig(
            instructions="You are a helpful assistant.",
        ),
    )

gradbot.routes.setup registers /api/audio-config, serves your static files, and automatically serves the bundled JS audio processor at /static/js/.

WebSocket Protocol

Direction Format Description
Client → Server JSON {"type": "start", ...} Begin session
Client → Server Binary Audio data
Client → Server JSON {"type": "config", ...} Reconfigure mid-session
Client → Server JSON {"type": "stop"} End session
Server → Client JSON Transcripts, events, audio timing
Server → Client Binary Audio data

API Reference

Functions

  • run(...): Create clients and start a session. Returns (SessionInputHandle, SessionOutputHandle).
  • create_clients(...): Create reusable GradbotClients for multiple sessions.
  • init_logging(): Initialize debug logging.

Enums

Enum Values
Lang En, Fr, Es, De, Pt
Gender Masculine, Feminine
Country Us, Gb, Fr, De, Mx, Es, Br
AudioFormat OggOpus, Pcm, Ulaw

Classes

  • SessionConfig: voice_id, instructions, language, assistant_speaks_first, silence_timeout_s, tools
  • ToolDef: name, description, parameters_json
  • SessionInputHandle: send_audio(bytes), send_config(SessionConfig), close()
  • SessionOutputHandle: receive() -> MsgOut | None
  • MsgOut: msg_type is one of "audio", "tts_text", "stt_text", "event", "tool_call"
  • ToolCallInfo: call_id, tool_name, args_json
  • ToolCallHandlePy: send(result_json), send_error(error_message)

Examples

See demos/ for complete examples including tool calling, voice switching, and WebSocket frontends.

Metadata

Release files for gradbot 0.2.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 gradbot 0.2.0
File Size Uploaded Provenance
gradbot-0.2.0.tar.gz 457.8 kB Without provenance Details

Built distributions (wheels)

Table of built distributions (wheels) for gradbot 0.2.0
File
gradbot-0.2.0-cp314-cp314t-musllinux_1_2_x86_64.whl CPython 3.14 CPython 3.14 free-threading Linux musl 1.2+ x86-64 Details
gradbot-0.2.0-cp314-cp314-win_amd64.whl CPython 3.14 CPython 3.14 Windows x86-64 Details
gradbot-0.2.0-cp314-cp314-musllinux_1_2_x86_64.whl CPython 3.14 CPython 3.14 Linux musl 1.2+ x86-64 Details
gradbot-0.2.0-cp314-cp314-manylinux_2_17_x86_64.manylinux2014_x86_64.whl CPython 3.14 CPython 3.14 Linux glibc 2.17+ x86-64 Details
gradbot-0.2.0-cp314-cp314-macosx_11_0_arm64.whl CPython 3.14 CPython 3.14 macOS 11.0+ ARM64 Details
gradbot-0.2.0-cp313-cp313-win_amd64.whl CPython 3.13 CPython 3.13 Windows x86-64 Details
gradbot-0.2.0-cp313-cp313-musllinux_1_2_x86_64.whl CPython 3.13 CPython 3.13 Linux musl 1.2+ x86-64 Details
gradbot-0.2.0-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl CPython 3.13 CPython 3.13 Linux glibc 2.17+ x86-64 Details
gradbot-0.2.0-cp313-cp313-macosx_11_0_arm64.whl CPython 3.13 CPython 3.13 macOS 11.0+ ARM64 Details
gradbot-0.2.0-cp312-cp312-win_amd64.whl CPython 3.12 CPython 3.12 Windows x86-64 Details
gradbot-0.2.0-cp312-cp312-musllinux_1_2_x86_64.whl CPython 3.12 CPython 3.12 Linux musl 1.2+ x86-64 Details
gradbot-0.2.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl CPython 3.12 CPython 3.12 Linux glibc 2.17+ x86-64 Details
gradbot-0.2.0-cp312-cp312-macosx_11_0_arm64.whl CPython 3.12 CPython 3.12 macOS 11.0+ ARM64 Details

Total release size: 67.4 MB

Release files / gradbot-0.2.0.tar.gz

Download URL gradbot-0.2.0.tar.gz
Size 457.8 kB
Tags Source
SHA-256 checksum
How to use checksums
826e720026a22114bbaa66f6e9f5d6e1fa9fb8505bdd257088a7d5a0d49ed750
BLAKE2b-256 checksum
How to use checksums
d32df4b65c9ebd0a0d758f9a81c74baa4c54728993328273b057b002f4ec1dac
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via maturin/1.14.1

Release files / gradbot-0.2.0-cp314-cp314t-musllinux_1_2_x86_64.whl

Download URL gradbot-0.2.0-cp314-cp314t-musllinux_1_2_x86_64.whl
Size 5.7 MB
Tags CPython 3.14 CPython 3.14 free-threading Linux musl 1.2+ x86-64
SHA-256 checksum
How to use checksums
9c3442fd3cf047f89391912209f042981965a31b40a6beec5eeb715ffe326e15
BLAKE2b-256 checksum
How to use checksums
fb85a1a0470186dcb008fe3d4fe3388be0eedbb7873996cd8c43088800aad988
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via maturin/1.14.1

Release files / gradbot-0.2.0-cp314-cp314-win_amd64.whl

Download URL gradbot-0.2.0-cp314-cp314-win_amd64.whl
Size 4.6 MB
Tags CPython 3.14 Windows x86-64
SHA-256 checksum
How to use checksums
e678c3454477042d01ae201fc2dea0c9eb96c05802f7d8a81af1182b1b805ab5
BLAKE2b-256 checksum
How to use checksums
03c4512b3ce1a7cb10f906b547482a5923cb344a2c82caa34790e05ab5228b29
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via maturin/1.14.1

Release files / gradbot-0.2.0-cp314-cp314-musllinux_1_2_x86_64.whl

Download URL gradbot-0.2.0-cp314-cp314-musllinux_1_2_x86_64.whl
Size 5.7 MB
Tags CPython 3.14 Linux musl 1.2+ x86-64
SHA-256 checksum
How to use checksums
41eeaac90b845b80313f4d7d08c72eb8f09f0512cd8be4852e12cc1855c5f5d7
BLAKE2b-256 checksum
How to use checksums
b8622dd760b353a981ec091e7f0e2cb2abb9a8fb07c7cea6b331549f96984b0a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via maturin/1.14.1

Release files / gradbot-0.2.0-cp314-cp314-manylinux_2_17_x86_64.manylinux2014_x86_64.whl

Download URL gradbot-0.2.0-cp314-cp314-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Size 5.5 MB
Tags CPython 3.14 Linux glibc 2.17+ x86-64
SHA-256 checksum
How to use checksums
efaf6ca2dbe60de752c9f93ef8313e8618d0f155ad760bba5b6b58ef3da9cb8f
BLAKE2b-256 checksum
How to use checksums
7b578408675b7f3046d045846cb58a31e6a5284ac6d05ee2f9b4ca7464e301a9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via maturin/1.14.1

Release files / gradbot-0.2.0-cp314-cp314-macosx_11_0_arm64.whl

Download URL gradbot-0.2.0-cp314-cp314-macosx_11_0_arm64.whl
Size 4.7 MB
Tags CPython 3.14 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
9e1289113cca99edcf5c340a764a0af71a0b147b746d985494f28cb0f2a9f9bf
BLAKE2b-256 checksum
How to use checksums
cb3194ac955958bf201666061babd52bff8aeb1f7fd373fbef33559a5f87cb6f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via maturin/1.14.1

Release files / gradbot-0.2.0-cp313-cp313-win_amd64.whl

Download URL gradbot-0.2.0-cp313-cp313-win_amd64.whl
Size 4.6 MB
Tags CPython 3.13 Windows x86-64
SHA-256 checksum
How to use checksums
42df83c2c6e344ab9d00270c96d00d31f5e8055b08feb48ae787f19d9f6a8171
BLAKE2b-256 checksum
How to use checksums
05c1d9d765c6b0e8a6ad33a4d0cd60edc429ddc60bd997cf846b033b2307e059
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via maturin/1.14.1

Release files / gradbot-0.2.0-cp313-cp313-musllinux_1_2_x86_64.whl

Download URL gradbot-0.2.0-cp313-cp313-musllinux_1_2_x86_64.whl
Size 5.7 MB
Tags CPython 3.13 Linux musl 1.2+ x86-64
SHA-256 checksum
How to use checksums
678dfbfb5ba213ef72c65842bbbe8a8bd68a44f2511f7768afe10fbb7359eb9b
BLAKE2b-256 checksum
How to use checksums
4580820f5f8e70cd4cb57730479c979dfef80164b12c9f3c3d4011edb6761f46
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via maturin/1.14.1

Release files / gradbot-0.2.0-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl

Download URL gradbot-0.2.0-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Size 5.5 MB
Tags CPython 3.13 Linux glibc 2.17+ x86-64
SHA-256 checksum
How to use checksums
c8b05ff446efbe9b5ad1dad72cf7110cfd8bb3ac6d11fa461e613365b4801e24
BLAKE2b-256 checksum
How to use checksums
cc55acf2dc0b866f9337b45e2cf04e90f50fc58773cc533e40985280d906440e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via maturin/1.14.1

Release files / gradbot-0.2.0-cp313-cp313-macosx_11_0_arm64.whl

Download URL gradbot-0.2.0-cp313-cp313-macosx_11_0_arm64.whl
Size 4.7 MB
Tags CPython 3.13 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
c4419a46615b05cb1cc25265eb371e37300a2f163fc06cf149c80d43d87648ac
BLAKE2b-256 checksum
How to use checksums
0fc72c9adc836e8926380069492088d550cb9db867b6d7ccb0ed1f91847ebe95
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via maturin/1.14.1

Release files / gradbot-0.2.0-cp312-cp312-win_amd64.whl

Download URL gradbot-0.2.0-cp312-cp312-win_amd64.whl
Size 4.6 MB
Tags CPython 3.12 Windows x86-64
SHA-256 checksum
How to use checksums
f54b007c9d355a27c85faebc55e01d2c18911c6fc3c30212528e02ed8d570d67
BLAKE2b-256 checksum
How to use checksums
b366aa9ed9956c76ab5fd98333b4e7d6b3b50bebf18479b39988fdb804a2ff32
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via maturin/1.14.1

Release files / gradbot-0.2.0-cp312-cp312-musllinux_1_2_x86_64.whl

Download URL gradbot-0.2.0-cp312-cp312-musllinux_1_2_x86_64.whl
Size 5.7 MB
Tags CPython 3.12 Linux musl 1.2+ x86-64
SHA-256 checksum
How to use checksums
9bead035ec234faecec0766002f29480f0bf27d30c42293492ec29d040e65594
BLAKE2b-256 checksum
How to use checksums
c0e899f95a8a739f114eb6a927b70da0d36e765b1ca0140ae7d04d04de41c788
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via maturin/1.14.1

Release files / gradbot-0.2.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl

Download URL gradbot-0.2.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Size 5.5 MB
Tags CPython 3.12 Linux glibc 2.17+ x86-64
SHA-256 checksum
How to use checksums
c4329b64df297a4a39ce53278091add0beb11e44eee5e34e5b9d7ac570e4a487
BLAKE2b-256 checksum
How to use checksums
6e18e97c794d6c11543fb57919d4d5b20afd76ee7b3c4f341534e4acb9292bb9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via maturin/1.14.1

Release files / gradbot-0.2.0-cp312-cp312-macosx_11_0_arm64.whl

Download URL gradbot-0.2.0-cp312-cp312-macosx_11_0_arm64.whl
Size 4.7 MB
Tags CPython 3.12 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
3a9c03cacffe4d8c9828d62a5a126601e0790e89a73f8f385ebe96861c354dfe
BLAKE2b-256 checksum
How to use checksums
f1d8e8c8319cb6ebb43b7dab5a89fcaa08d3d51836fb29da95998dc4414852b5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via maturin/1.14.1

Security for gradbot 0.2.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.

No provenance found

None of the files in this release were uploaded with provenance metadata.

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