Skip to main content
TurnCall supports browser-based voice calls via WebRTC using Pipecat’s SmallWebRTCTransport. Audio flows peer-to-peer at 16kHz.

SDP Signaling

Connect

Send an SDP offer and receive an answer:
Starting a call needs an admin or developer key, as for an outbound call or a chat session; a viewer key gets 403. The answer carries the call id alongside the SDP:
That is the handle for everything after the call — its transcript, its recording, or converting it into an eval scenario. A client that only reads sdp and type is unaffected. An offer that names the pc_id of a connection that is still open — a client restarting ICE, or renegotiating its tracks — is that same call: it is answered under the same call_id, and runs no call-init and creates no new call. A pc_id from another project’s call is a 404. If the agent cannot start (a provider with no key, say), there is no answer to give: the response is 500 with code pipeline_start_failed, the reason, and details.missing_keys when keys are missing. The call is recorded as failed.
A call that does start and then loses a provider ends like any other from the browser’s side. Its error.raised event says why; see When a call fails.

ICE Trickle

The trickle needs the same kind of key as the POST that opened the connection (admin or developer), for the project whose call it is. Without a key it is a 401; a pc_id no call of that project holds is a 404, whether it exists or not. pipecat’s browser transport sends the headers it was given for the POST on every PATCH too, so a client that set Authorization there needs nothing more.

Behind NAT: a TURN relay

TurnCall’s side of the call gathers its candidates with public STUN by default, which works when the server has a public address. Behind NAT — a Kubernetes pod, or a Cloudflare Container, which takes no inbound UDP at all — the browser can connect and still hear nothing. Give it a TURN relay with WEBRTC_ICE_SERVERS, as JSON in the browser’s RTCIceServer shape:
Only the first TURN entry is used. TURN over TLS on port 443 is the one that gets out of the most networks.

The greeting

The agent’s first_message is spoken once the browser’s peer connection is up, not when the pipeline starts: audio written before the connection is dropped, so a greeting that beat ICE and DTLS used to play to nobody.

Dynamic Routing

Pass server_url in requestData for pre-call initialization:
See Pre-Call Init for response format. Outside development (TURNCALL_ENV other than development, staging included) server_url must be https://, or a Kubernetes Service in the same cluster (http://<name>.<namespace>.svc.cluster.local/...), whose traffic never leaves it; any other http:// URL is refused with a 400. ALLOW_PLAIN_HTTP_URLS overrides the default: true allows plain http everywhere, false refuses it in development too.

Template Variables

variables in requestData fill the agent’s {{placeholders}} (system prompt, first message, tool descriptions) for this call:
A flat object of strings, numbers or booleans, at most 50 names and 4,096 characters — anything else is a 400. With server_url, call-init receives them as call.variables, and on a clash with call-init’s own variables the request’s value wins.

Browser Client

See the examples/webrtc-client directory for a complete browser client using Pipecat JS SDK + WebRTC.

Video Avatar

WebRTC agents, cascade or speech-to-speech, can add a lip-synced video avatar (HeyGen or Tavus). See Video Avatar.