Python bindings for gradbot voice AI library
Project description
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="YTpq7expH9539ERJ",
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.fastapi module provides a WebSocket handler and route setup for building voice demos.
from fastapi import FastAPI, WebSocket
from gradbot.fastapi import websocket_chat_handler, setup_demo_routes
app = FastAPI()
setup_demo_routes(app, static_dir="static", voices=True)
@app.websocket("/ws")
async def ws(websocket: WebSocket):
await websocket_chat_handler(
websocket,
on_start=lambda msg: gradbot.SessionConfig(
instructions="You are a helpful assistant.",
),
)
setup_demo_routes 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 reusableGradbotClientsfor multiple sessions.flagship_voices()— List all available voices.flagship_voice(name)— Look up a voice by name (case-insensitive).voices_json()— All voices as JSON-serializable dicts.voice_switching_tools()—ToolDeflist forswitch_to_{name}tools.resolve_voice_from_tool(tool_name)— Resolve aswitch_to_*tool name to aFlagshipVoice.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 (24kHz in / 48kHz out), Ulaw (G.711 mu-law) |
Classes
SessionConfig—voice_id,instructions,language,assistant_speaks_first,silence_timeout_s,toolsToolDef—name,description,parameters_jsonSessionInputHandle—send_audio(bytes),send_config(SessionConfig),close()SessionOutputHandle—receive() -> MsgOut | NoneMsgOut—msg_typeis one of"audio","tts_text","stt_text","event","tool_call"ToolCallInfo—call_id,tool_name,args_jsonToolCallHandlePy—send(result_json),send_error(error_message)
Examples
See demos/ for complete examples including tool calling, voice switching, and WebSocket frontends.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file gradbot-0.1.3.tar.gz.
File metadata
- Download URL: gradbot-0.1.3.tar.gz
- Upload date:
- Size: 391.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: maturin/1.12.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2673524d24ac5f12a60b24ed309ac52ca3cd8535f5489ca2478748141756e9ed
|
|
| MD5 |
cb157d95af91f69b246aa782a431835d
|
|
| BLAKE2b-256 |
dba3dff45be37d24814b43cf6b3ad0bd32148985295da6235506a19519ee2dcb
|
File details
Details for the file gradbot-0.1.3-cp314-cp314t-musllinux_1_2_x86_64.whl.
File metadata
- Download URL: gradbot-0.1.3-cp314-cp314t-musllinux_1_2_x86_64.whl
- Upload date:
- Size: 5.8 MB
- Tags: CPython 3.14t, musllinux: musl 1.2+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: maturin/1.12.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1ac0e06b791d364454fc958ef9b7c63b4c0a0a26551c0c7dcc9462b2f77369d8
|
|
| MD5 |
06a29c1f6a0c2fc563922689cfebecd8
|
|
| BLAKE2b-256 |
923fbc4d248ff99bd1a28af46d2a93fa7e886b580393337dad156b45fa9d23a4
|
File details
Details for the file gradbot-0.1.3-cp314-cp314-win_amd64.whl.
File metadata
- Download URL: gradbot-0.1.3-cp314-cp314-win_amd64.whl
- Upload date:
- Size: 4.7 MB
- Tags: CPython 3.14, Windows x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: maturin/1.12.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
81c6ce4e134431e042701ee567e614f38ef57a45cf21c30112c036f31a6dfc1c
|
|
| MD5 |
4a2d7bd567ab47cec6f746f39ec1379e
|
|
| BLAKE2b-256 |
57b1ced724330d2bb4dab75ab0a0a2112006f624d4537aed07b59bcc7d6333d1
|
File details
Details for the file gradbot-0.1.3-cp314-cp314-musllinux_1_2_x86_64.whl.
File metadata
- Download URL: gradbot-0.1.3-cp314-cp314-musllinux_1_2_x86_64.whl
- Upload date:
- Size: 5.8 MB
- Tags: CPython 3.14, musllinux: musl 1.2+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: maturin/1.12.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
98364bf905ceb400811a10daade647de6a5774293f89a40fd30a544886bc9376
|
|
| MD5 |
ac797b9a69a4031866a2e82b45fef11c
|
|
| BLAKE2b-256 |
6490c41825915abda97173b441fee9c20a716a525322212997368e796ba186de
|
File details
Details for the file gradbot-0.1.3-cp314-cp314-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.
File metadata
- Download URL: gradbot-0.1.3-cp314-cp314-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 5.6 MB
- Tags: CPython 3.14, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: maturin/1.12.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
30187d5bd7a1617569756a7649c1ae718cdbdc88c3d9884b32c4e1b68f70252b
|
|
| MD5 |
9e162087a16541e505a2983beb9c76d2
|
|
| BLAKE2b-256 |
c70d65102f856aee5da8aa05a1d00750dcf2fed6a9a6032bb976586198876706
|
File details
Details for the file gradbot-0.1.3-cp314-cp314-macosx_11_0_arm64.whl.
File metadata
- Download URL: gradbot-0.1.3-cp314-cp314-macosx_11_0_arm64.whl
- Upload date:
- Size: 4.9 MB
- Tags: CPython 3.14, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: maturin/1.12.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d06b6d48f7daaf7c9734abe311a26a96655291de684384e846180cfcc4d52ae4
|
|
| MD5 |
64910ba7a25284f5b6bb9d394024d367
|
|
| BLAKE2b-256 |
df2cb9fe1e10f27a75dd93354af0119bf20d08603f26c228a6f6b0c064da0142
|
File details
Details for the file gradbot-0.1.3-cp313-cp313t-musllinux_1_2_x86_64.whl.
File metadata
- Download URL: gradbot-0.1.3-cp313-cp313t-musllinux_1_2_x86_64.whl
- Upload date:
- Size: 5.8 MB
- Tags: CPython 3.13t, musllinux: musl 1.2+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: maturin/1.12.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1b018a1bd7969fb658e4723f5bed9b0de63838b95b01b3a678d8af08c223201b
|
|
| MD5 |
abe282b4f7c190bce8415b6c082547c5
|
|
| BLAKE2b-256 |
d8795e10b100ff335c0f38f815a5a3954e7e5423460381de0bad7e797e8d3b50
|
File details
Details for the file gradbot-0.1.3-cp313-cp313-win_amd64.whl.
File metadata
- Download URL: gradbot-0.1.3-cp313-cp313-win_amd64.whl
- Upload date:
- Size: 4.7 MB
- Tags: CPython 3.13, Windows x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: maturin/1.12.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c31289c0289710112e487d32338e56f6bcd75fc9570bed0def7308a536b0ac73
|
|
| MD5 |
7b467ddefc7e88f41eb3e8735d6a2716
|
|
| BLAKE2b-256 |
fa4fec96933a4a15440fa6fedecde15dd42f5d29373aa524dbda40868251863b
|
File details
Details for the file gradbot-0.1.3-cp313-cp313-musllinux_1_2_x86_64.whl.
File metadata
- Download URL: gradbot-0.1.3-cp313-cp313-musllinux_1_2_x86_64.whl
- Upload date:
- Size: 5.8 MB
- Tags: CPython 3.13, musllinux: musl 1.2+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: maturin/1.12.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
aeee22d015a78d61ca569f5da9d5005eb296748b1ad4f3eac8c78c080b556ca4
|
|
| MD5 |
d6357843506df3a4010e2d64b3658589
|
|
| BLAKE2b-256 |
b247234e0365cc9c259b8c21b69fbb8d664c5c14e3ce6bedec0f3793c5c7564d
|
File details
Details for the file gradbot-0.1.3-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.
File metadata
- Download URL: gradbot-0.1.3-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 5.6 MB
- Tags: CPython 3.13, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: maturin/1.12.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f96a80a4007a49bee1b5a65abfae1165f667d5e9868a95999fd31e18bd589a5b
|
|
| MD5 |
61c94053aa72bec66f4bb19b3b6cfe9e
|
|
| BLAKE2b-256 |
3ad4849780f028a6b95fc2a25d564ef49c783084a7ec54472adba0cd591b5298
|
File details
Details for the file gradbot-0.1.3-cp313-cp313-macosx_11_0_arm64.whl.
File metadata
- Download URL: gradbot-0.1.3-cp313-cp313-macosx_11_0_arm64.whl
- Upload date:
- Size: 4.9 MB
- Tags: CPython 3.13, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: maturin/1.12.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
246739ee708287e4e604f236a1702a9b597299db627de8ff9107a1589689fc6f
|
|
| MD5 |
8f6e81f2f620051c77dc71565f183f8a
|
|
| BLAKE2b-256 |
4926be655979ec7146384452927e26608ce2b3619f88eb6d11c2ab8669cee0cb
|
File details
Details for the file gradbot-0.1.3-cp312-cp312-win_amd64.whl.
File metadata
- Download URL: gradbot-0.1.3-cp312-cp312-win_amd64.whl
- Upload date:
- Size: 4.7 MB
- Tags: CPython 3.12, Windows x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: maturin/1.12.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
abc31551138f52ccdb5ca5dc9a3b911e3ebcf7389bcb79042e8fbecda9ac9eb0
|
|
| MD5 |
81dadb33566204aaf05d4a98b12bf746
|
|
| BLAKE2b-256 |
40da45e8dd5e22f480685c1e84b8844ba72bc8d29ecb85e1786505e2cd285146
|
File details
Details for the file gradbot-0.1.3-cp312-cp312-musllinux_1_2_x86_64.whl.
File metadata
- Download URL: gradbot-0.1.3-cp312-cp312-musllinux_1_2_x86_64.whl
- Upload date:
- Size: 5.8 MB
- Tags: CPython 3.12, musllinux: musl 1.2+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: maturin/1.12.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
cdba1315e31233dea2620fc46b8a06d7232ac99503526703809fd9787619bca7
|
|
| MD5 |
922c908870e278c95270ead4180656d6
|
|
| BLAKE2b-256 |
274e85449ad15a9d8631d049d5b2b14d5314acc461fef4bcdaa0c43e41a82883
|
File details
Details for the file gradbot-0.1.3-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.
File metadata
- Download URL: gradbot-0.1.3-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 5.6 MB
- Tags: CPython 3.12, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: maturin/1.12.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
354e10d6f6bf6a0a34aaec27411a1bf86e74c98bbc82f20454d826d6a903597e
|
|
| MD5 |
0759dfafcf527573080efbf589a1964d
|
|
| BLAKE2b-256 |
a48865784de502bc14ddc6194d7277bbb096765248bbf6f3415c008ad8916ad0
|
File details
Details for the file gradbot-0.1.3-cp312-cp312-macosx_11_0_arm64.whl.
File metadata
- Download URL: gradbot-0.1.3-cp312-cp312-macosx_11_0_arm64.whl
- Upload date:
- Size: 4.9 MB
- Tags: CPython 3.12, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: maturin/1.12.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
98f329b2ef37b2789dfce1e19dedf3996f788f437f5ba4ad6b435939b535f7fb
|
|
| MD5 |
8f9cf648a5c30564e37628b17cf0aa05
|
|
| BLAKE2b-256 |
8c152c04971f3fdca74da94fb7d52c09e2f56f5ab914bdf4439890578fc27aa3
|