This guide covers both the Python SDK (
tuner-livekit-sdk) and the Node.js SDK (@usetuner.ai/livekit-sdk). Use the language switcher below to view the guide for your stack.Video Tutorial
Prerequisites
- Tuner Active Account
- Configured Agent with provider “Custom API” in Tuner
- A LiveKit Agents project, either:
- Python running LiveKit Agents v1.4 or later, or
- Node.js 18+ running
@livekit/agentsv1.4 or later with@livekit/rtc-nodev0.13 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. It ships in two flavours that share the same wire format and feature set: a Python package and a Node.js package.1
Install the SDK
Add the package to your project.
2
Set Your Credentials
Configure your Tuner API key, workspace ID, and agent remote ID.
3
Add the Plugin
Drop two lines into your entrypoint and you’re done.
- Python
- Node.js
Step 1: Install the SDK
livekit-agents >= 1.4, aiohttp >= 3.9Step 2: Set Your Credentials
You can configure credentials via environment variables or pass them directly in code.- Environment Variables
- Inline in Code
Step 3: Add the Plugin
ImportTunerPlugin and add it right after creating your AgentSession — before calling session.start():SIP correlation for simulation
To run Call Simulation against this agent, pass the inbound call’s SIPCall-ID as sip_correlation_id. For why Tuner needs it and how the value can change name in transit, see Simulation SIP setup.This applies to inbound simulation, where Tuner dials your agent. For outbound simulation, pass the dialed SIP URI as
recipient instead — see Outbound Simulation.sip.callIDFull attribute.Requires
tuner-livekit-sdk >= 0.1.5.Helper: extract the SIP correlation ID
Add this helper to your entrypoint module. It scans the room’s remote participants for the SIP participant and returns itssip.callIDFull attribute.None and TunerPlugin falls back to its normal behaviour.Wire it into your entrypoint
The SIP participant only becomes visible after the agent joins the room. Callctx.connect() first, then read the correlation ID, then pass it to TunerPlugin:Disconnection Reasons
Tuner captures why each call ended. User disconnects and errors are tracked automatically. To record agent-initiated hangups, passreason="agent_hangup" when ending the call programmatically:Full tool call example
Full tool call example
drain=True lets any in-flight audio finish before the session closes. Omit it for an immediate cutoff.LangChain / LangGraph observability
Using LangGraph or LangChain for your logic layer? The plugin can capture node transitions, tool calls, and timing alongside session data. See LangChain / LangGraph.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:Recipient
Recipient
The phone number or SIP URI of the callee. Optional — pass it when you want to record who the call was directed to:
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 matches your pricing plan; the snippet below is illustrative.Extra Metadata
Extra Metadata
Attach arbitrary key-value data to every call record:
Retry and Timeout
Retry and Timeout
Agent Version Tracking
Agent Version Tracking
Track which version of your agent handled each call — useful when you update a prompt, swap a model, or change your pipeline:Tuner reads it automatically. Bump the number on every deployment.Override in code (takes priority over the env var):
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_IDis the Agent Remote ID from Agent Settings → Agent Connection (not your agent’s display name). - Confirm
TUNER_WORKSPACE_IDis correct. - Check your application logs for any error messages from the plugin.
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.
Webhooks
Tuner can notify your systems when it has something to report on a call — see Webhooks.What’s Next?
Configuring Your Agent
Set up call outcomes, user intents, and evals.
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.