Installation
httpx>=0.24.0, pydantic>=2.0.0
Authentication
Every client call injects your API key as theX-API-Key header. Generate a key from app.vaanivoice.ai → Settings → API Keys.
| Parameter | Description | Default |
|---|---|---|
api_key | Your Vaani API key (X-API-Key) | (required) |
base_url | Base URL of the Vaani API | https://api.vaanivoice.ai |
timeout | Request timeout in seconds | 120.0 |
Outbound Calls
Trigger a Call
| Parameter | Type | Required | Description |
|---|---|---|---|
agent_id | str | Yes | Agent UUID from the Agent Config dashboard |
contact_number | str | Yes | Phone number in E.164 format (e.g. +919876543210) |
name | str | Yes | Contact display name |
voice | str | No | Override the agent’s default voice for this call |
metadata | dict | No | Template variables injected into the agent’s prompt |
outbound_number | str | No | Override caller ID (must be configured in Telephony settings) |
Call History
Transcript and Call Details
Stream Audio
WebRTC Voice Sessions
Useclient.sessions to create and manage real-time voice sessions powered by LiveKit.
Flow Overview
Create a session
Call
client.sessions.create(...) to get a session_token and an embeddable session_url.Connect and get LiveKit credentials
Call
client.sessions.connect(session_token) to obtain lk_url and lk_token.Join via LiveKit
Pass
lk_url and lk_token to the LiveKit client SDK in your browser or mobile app to establish the WebRTC connection.Quickstart
sessions.create() Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
agent_id | str | required | Agent UUID or name |
ui_type | str | "fullpage" | Display mode: "fullpage" or "widget" |
grace_period | int | None | Reconnection window in seconds (0–3600) |
session_ttl | int | None | Session lifetime in seconds (60–86400, default 30 min) |
initial_message | str | None | Message injected into agent context at session start |
metadata | dict | None | Arbitrary key-value data forwarded to the agent |
Real-Time Session Events
Connect to the WebSocket URL to receive push events while the session is active:Agent Management
Create an Agent
List and Inspect Agents
Update Agent Configuration
Async Usage
Every method has an exact async equivalent onAsyncVaaniClient, including all resource namespaces.
Error Handling
All SDK exceptions inherit fromVaaniError and carry a .status_code attribute.
| Exception | HTTP status | Cause |
|---|---|---|
AuthenticationError | 401 | Invalid or missing API key |
ForbiddenError | 403 | Operation not allowed for this API key |
NotFoundError | 404 | Resource does not exist |
SessionExpiredError | 410 | WebRTC session has ended or expired |
InsufficientBalanceError | 402 | Wallet balance too low |
ValidationError | 422 | Request parameters failed validation |
RateLimitError | 429 | Too many requests |
ServerError | 5xx | Vaani server-side error |
TimeoutError | — | Request timed out |
ConnectionError | — | Could not reach the API |

