This guide covers the Python SDK. JavaScript support is coming soon.
Prerequisites
- Tuner Active Account
- Configured Agent with provider “Custom API” in Tuner
- Python project running LiveKit Agents v1.4 or later.
Overview
The tuner-livekit SDK automatically captures session data from your LiveKit agent and sends it to Tuner when the call ends — no manual API calls required.
Estimated time: 2 minutes from start to finish
Step 1: Install the SDK
livekit-agents >= 1.4, aiohttp >= 3.9
Step 2: Set Your Credentials
You can configure credentials via environment variables or pass them directly in code.- Environment Variables
- Inline in Code
| Variable | Required | Description |
|---|---|---|
TUNER_API_KEY | ✅ | Bearer token (starts with tr_api_) |
TUNER_WORKSPACE_ID | ✅ | Your Tuner workspace ID |
TUNER_AGENT_ID | ✅ | Agent identifier from Agent Settings |
TUNER_BASE_URL | — | API base URL (default: https://api.usetuner.ai) |
Step 3: Add the Plugin
ImportTunerPlugin and add it right after creating your AgentSession — before calling session.start():
Configuration Options
Call Type
Call Type
The plugin auto-detects the call type (
phone_call for SIP participants, web_call otherwise). Override it explicitly when needed:Recording URL
Recording URL
Tuner requires a
recording_url for every call. Provide a resolver function that returns the URL. If you don’t provide one, the plugin submits "pending" as a placeholder.Cost Calculation
Cost Calculation
Provide a callable that receives a
UsageSummary and returns the call cost in USD Cents. Implement the method that match your pricing plan. the below implementation is just for example.Extra Metadata
Extra Metadata
Attach arbitrary key-value data to every call record:
Retry and Timeout
Retry and Timeout
Disable the Plugin
Disable the Plugin
Useful for local development or test environments:
Full Example
Troubleshooting
Calls don't appear in Tuner
Calls don't appear in Tuner
- Verify that
TUNER_AGENT_IDmatches the Agent ID configured in Tuner under Agent Settings > Agent Connection. - Confirm
TUNER_WORKSPACE_IDis correct. - Check your application logs for any error messages from the plugin.
Unauthorized (401)
Unauthorized (401)
Recording URL shows as 'pending'
Recording URL shows as 'pending'
- You haven’t provided a
recording_url_resolver. Add one that returns the actual recording URL for each call. - If using LiveKit Egress, ensure the recording has finished processing before the resolver is called.
What’s Next?
Configuring Your Agent
Set up call outcomes, user intents, and behavior checks.
Custom Integration
Learn about the underlying API if you need more control.
Classifying Calls
Define how Tuner categorizes your calls.
Real-Time Alerts
Get notified when issues are detected.