Introducing Confident Voice: Watch the Launch Video Now

WebRTC for Voice Connections

Join your voice agent through LiveKit, Pipecat, or your own signaling URL, and link each call to its trace.

Included on the Enterprise plan. Book a demo, opens in a new tab. Included on the Team plan. Included on the Starter plan. Not included on the Free plan.

Overview

Use the WebRTC transport when your voice agent talks over WebRTC instead of a phone line. Confident AI joins your agent as a participant and talks to it over audio. Choose your Provider at the top of the WebRTC tab:

  • LiveKit (default): your agent runs on LiveKit.
  • Pipecat: your agent runs on Pipecat, on Pipecat Cloud or your own server.
  • Custom signaling: your agent accepts an SDP offer at a URL you host.

WebRTC calls don't ring, so the Ring timeout call limit doesn't apply and the Test call console shows Connect instead of Dial.

Configuring Your Provider

Confident AI creates a room in your LiveKit project, dispatches your agent into it, and joins as the caller.

FieldDescription
LiveKit URLYour LiveKit server URL. It must start with wss://, for example wss://your-project.livekit.cloud.
API keyThe API key of the LiveKit project your agent runs in. Found under Settings → Keys in LiveKit Cloud.
API secretThe API secret paired with the key. Used to mint the token the simulated caller joins the room with.
Agent name (optional)The agent to dispatch into the room. Leave it blank if your agent joins every new room automatically.
Dispatch metadata (optional)Values sent to your agent as JSON when each call starts, as fixed key-value pairs or built by code from each call's golden. See Passing Data to Your Agent.

Passing Data to Your Agent

Use Dispatch metadata (LiveKit) or Request body (Pipecat) to pass your agent any values it needs at the start of a call. Pick how the values are built with the tabs above the field:

  • Key-value: fixed pairs, sent the same with every call on the connection. Use it for settings of the agent itself.
  • Code: a Python function that builds the values from each simulated call's golden. Use it when the values depend on the test case, so one connection can cover goldens that need different values.

Building Values From the Golden

In Code mode, define generate_payload. It receives the conversational golden behind the simulated call and returns a dict, which is sent to your agent as is:

from deepeval import ConversationalGolden


def generate_payload(golden: ConversationalGolden) -> dict:
    return {"your_key": golden.additional_metadata["your_key"]}

The golden has every field it has in the dataset, such as scenario, expected_outcome, user_description, persona and additional_metadata. Type golden. in the editor to see them all.

  • The code runs once for each simulated call. Test calls from the Test call console have no golden, so nothing is sent for them.
  • Syntax errors are underlined as you type, and the connection can't be saved until they're fixed.
  • If the code raises an error or doesn't return a dict, the simulated call fails with that error.

Reading the Values

The values arrive as a JSON string in the job's metadata:

agent.py
import json

from livekit.agents import JobContext

async def entrypoint(ctx: JobContext):
    metadata = json.loads(ctx.job.metadata or "{}")
    value = metadata.get("your_key")

Dispatch metadata is sent with the agent dispatch, so it needs an Agent name.

Custom signaling has no equivalent; use Signaling headers to pass values to a custom agent.

Testing Your Connection

Click Connect in the Test call console. The console shows Connecting… while Confident AI joins your agent. See Testing Your Connection for what each result means.

Once your agent answers, a line under the result reads Waiting for trace with a View trace link. Your agent sends the trace after the call ends, so opening it early shows that it hasn't arrived yet and then the trace itself, a few seconds after the call ends. The line then reads Trace received, or No trace received if nothing arrived. Answered test calls under Recent calls are marked Traced once their trace arrives. See Linking Traces below.

Linking Traces

When your voice agent sends traces to Confident AI, each simulated call is linked to the trace your agent produced for it. The turns themselves stay as Confident AI transcribed them; linking adds the trace alongside them:

  • Trace per test case — a View trace link on the test case opens the trace behind the call, with every tool call, retrieval, and LLM step your agent took.
  • Span per turn — each turn gets a View span link that opens that turn's span, so you can see what your agent heard and did for that exact exchange. Both links appear with the turns, while the call is still going; opened before the trace arrives, they show that your agent hasn't sent it yet and then the trace or span once it lands.
  • No separate setup — the tracing you already use in production is all that simulations need.

Voice Frameworks

If your agent is built on LiveKit Agents or Pipecat and is traced with confident-trace, there is nothing else to set up. Confident AI handles linking behind the scenes: just make sure your agent is traced.

from confident_trace import init
from livekit.agents import AgentServer

init()
server = AgentServer()

See the LiveKit and Pipecat integrations for the full setup.

Custom Signaling

If you host your own WebRTC agent, Confident AI includes each call's test case ID as an X-Confident-Test-Case-Id header on the SDP offer. Read it where your agent accepts the call, and wrap the conversation in a trace_context / traceContext so every trace your agent produces is linked to that test case:

agent.py
import asyncio

from aiohttp import web
from confident_trace import init, trace_context

init()

async def offer(request: web.Request) -> web.Response:
    sdp = await request.text()
    answer, run_conversation = await start_call(sdp)
    test_case_id = request.headers.get("X-Confident-Test-Case-Id")

    async def traced():
        with trace_context(test_case_id=test_case_id):
            await run_conversation()

    asyncio.create_task(traced())
    return web.Response(text=answer, content_type="application/sdp")

How It Works

Every simulated call carries the ID of the test case it belongs to—in the LiveKit room name, in the Pipecat start request, or in the X-Confident-Test-Case-Id header. When your agent traces the call, that ID comes back on the trace, and Confident AI attaches the trace to the test case as soon as it arrives, whether the run is still going or has finished.

Turns are paired with the trace's turn spans by when they started: LiveKit records a span for each user turn and each agent turn, and Pipecat one turn span that covers both sides. A custom agent's traces are attached to the test case but not to individual turns.

Next Steps

Scaling beyond prototype?For teams evaluating Confident AI in productionTalk to us

Last updated on

Built byConfident AI