LiveKit Outbound Calling over Teler SIP: Complete Guide

This guide covers LiveKit SIP outbound calling integrated with Teler's WebSocket transport layer, verified against LiveKit v1.13.7 and Teler's API as documented in September 2026. Learn how audio flows from...
LiveKit SIP outbound calling routed through FreJun Teler to a live phone number.
In this article

AI Summary: This guide covers LiveKit SIP outbound calling integrated with Teler’s programmable voice API, written for backend and API integration engineers evaluating the livekit sip path in 2026. LiveKit documents a 30-second media timeout before the first RTP packet arrives, per the official SIP primer. Engineers must supply their own SIP trunk, phone number provisioning, and any resampling between LiveKit’s 8 kHz PCMU/PCMA codecs and a higher-bandwidth model stack. Teler handles carrier connectivity, real-time WebSocket audio streaming, and call control so the application layer stays above raw telephony.

Scope: This walkthrough covers outbound calling from a LiveKit room through a Teler SIP trunk to a PSTN destination, verified against LiveKit v1.13.7 and Teler’s WebSocket streaming API as documented in September 2026. It does not cover inbound SIP dispatch rules or LiveKit Cloud dashboard configuration.

Quick Answer: LiveKit SIP outbound calling in 2026 uses CreateSIPParticipant to dial a PSTN number through a configured SIP trunk. Teler provides that trunk, streams raw audio over WebSocket at 8 kHz or 16 kHz, and handles carrier connectivity. The call connects when the callee returns a SIP 200 OK, after which RTP carries the media.

The livekit sip outbound path requires a SIP trunk provider that bridges LiveKit’s room-bound media to the public telephone network. Teler fills that role by exposing a programmable SIP endpoint alongside a WebSocket audio stream that your application server reads and writes in real time.

What is LiveKit?

LiveKit is an open-source, distributed WebRTC SFU (Selective Forwarding Unit) that moves real-time audio, video, and data between people, devices, and AI models. It occupies the media-routing layer: it negotiates codecs, manages rooms, and forwards RTP tracks between participants. LiveKit does not provide PSTN connectivity, phone numbers, or carrier access. For any call that must reach a standard telephone, a developer must connect an external SIP trunk provider. The developer is also responsible for number provisioning, any resampling between LiveKit’s telephony codecs and a higher-bandwidth model stack, and jitter buffer tuning on the RTP path.

Why is livekit sip outbound calling harder than it looks?

The engineering constraint is not the SIP handshake. SIP (Session Initiation Protocol, defined in RFC 3261) is well-understood. The problem is what happens after the 200 OK: RTP (Real-time Transport Protocol, defined in RFC 3550) must flow within 30 seconds or LiveKit disconnects the call with a media timeout error. If at least one RTP packet has already arrived, the timeout shortens to 15 seconds. That window is tight when a model stack is cold-starting or when a firewall silently drops UDP. Beyond the timeout, there is a codec mismatch to manage: LiveKit’s default SIP codecs are PCMU and PCMA at 8000 Hz and G722, while many AI voice models operate at 16 kHz or 24 kHz. Any path that mixes those rates needs an explicit resampling step, and that step adds latency.

One-way silence after a successful SIP connect is the most common production failure in the LiveKit telephony community. The call is answered, the agent plays its intro, and then audio stops. The root cause is usually a missed track_subscribed event or a firewall blocking RTP media after the SIP signaling passes through.

LiveKit SIP call setup steps against the 30-second media timeout before the first RTP packet.

How does audio flow from carrier to model and back?

Understanding the full path prevents the class of bugs where audio is present at one hop and missing at the next. The table below maps each hop to its format, transport, and owner.

HopFormatSample rateTransportOwner
PSTN to Teler edgePCMU / PCMA (G.711)8000 HzSIP + RTPCarrier / Teler
Teler edge to your serverBase64-encoded PCM audio8k or 16k (configurable)WebSocket (JSON)Teler
Your server to STT enginePCM framesMatches STT requirementHTTP / WebSocketYour application
LLM response to TTSText tokensN/AHTTP / streamingYour application
TTS output to TelerBase64-encoded PCM audio8k or 16kWebSocket (JSON)Your application
Teler to LiveKit SIP participantPCMU / PCMA / G7228000 Hz or 16000 HzRTP / SRTPTeler / LiveKit

The codec negotiation between Teler and LiveKit follows the SDP offer/answer model defined in RFC 3264. LiveKit advertises its supported codecs in the SDP offer; Teler selects the best match. If you configure Teler to stream at 16k but the negotiated SIP codec is PCMU at 8000 Hz, your application must resample before injecting audio back into the call.

Prerequisites for livekit sip outbound integration

  • A LiveKit server instance (v1.13.7 or later) or a LiveKit Cloud project with SIP enabled
  • A Teler account with a provisioned DID (Direct Inward Dialing number) and SIP trunk credentials; see Teler API documentation for trunk setup
  • The LiveKit JavaScript server SDK: npm install livekit-server-sdk --save
  • A publicly reachable application server for the Teler WebSocket connection
  • Firewall rules that allow UDP RTP traffic between Teler’s edge and your LiveKit SIP endpoint; blocking this is the most common cause of answered-but-silent calls
  • E.164-formatted destination numbers (for example, +15551234567)
  • An STT engine, an LLM, and a TTS engine whose sample rates you have confirmed against Teler’s 8k or 16k stream options

How do you implement livekit sip outbound calling with Teler?

Step 1: Configure the Teler SIP trunk

Teler supports credential-based or IP-based SIP authentication. Create an outbound trunk in the Teler platform and note the trunk ID. You will reference this ID in every CreateSIPParticipant call. Teler’s SIP endpoint acts as the bridge between LiveKit’s room and the PSTN carrier.

# Using the LiveKit CLI to create a SIP participant via a stored Teler trunk
lk sip participant create \
  --room "my-agent-room" \
  --trunk "<TELER_SIP_TRUNK_ID>" \
  --call "+15551234567" \
  --identity "outbound-caller"

The --trunk flag references the stored outbound trunk; the --call flag takes an E.164 number. The CLI example above mirrors the pattern in the Telnyx LiveKit telephony reference, which shows the same CLI shape for SIP participant creation.

Step 2: Create the SIP participant from your server SDK

The JavaScript server SDK exposes the SIP service through the LiveKitAPI entry point. Call createSIPParticipant with a CreateSIPParticipantRequest object. The call is asynchronous; the returned participant joins the room once the callee answers.

import { LiveKitAPI } from 'livekit-server-sdk';

const api = new LiveKitAPI(
  process.env.LIVEKIT_URL,
  process.env.LIVEKIT_API_KEY,
  process.env.LIVEKIT_API_SECRET
);

const participant = await api.sip.createSIPParticipant({
  sipTrunkId: process.env.TELER_SIP_TRUNK_ID,
  sipCallTo: '+15551234567',
  roomName: 'my-agent-room',
  participantIdentity: 'outbound-caller',
  waitUntilAnswered: true,
});

console.log('SIP participant joined:', participant.participantIdentity);

Set waitUntilAnswered: true so the promise resolves only after the callee returns a SIP 200 OK. Without this, your agent may attempt to subscribe to the audio track before the call is established, which causes the track_subscribed event to fire before your handler is registered.

Step 3: Open the Teler WebSocket and stream audio

Once the SIP participant is in the room, open a WebSocket connection to Teler’s streaming endpoint. Teler sends inbound call audio as Base64-encoded PCM chunks. Your server decodes each chunk, passes it to your STT engine, feeds the transcript to your LLM, synthesizes a TTS response, and sends the audio back. Configure the stream at 8k or 16k sample rate to match your STT engine’s expectation.

import asyncio
import websockets
import json
import base64

async def handle_call_stream(ws_url: str, api_key: str):
    async with websockets.connect(
        ws_url,
        extra_headers={"Authorization": f"Bearer {api_key}"}
    ) as ws:
        # Configure stream: 8000 Hz, 400 ms chunks
        await ws.send(json.dumps({
            "type": "config",
            "sampleRate": 8000,
            "chunkSize": 400
        }))

        async for message in ws:
            event = json.loads(message)
            if event["type"] == "audio":
                pcm_bytes = base64.b64decode(event["data"])
                # Pass pcm_bytes to your STT engine here

async def send_tts_audio(ws, pcm_bytes: bytes):
    encoded = base64.b64encode(pcm_bytes).decode("utf-8")
    await ws.send(json.dumps({"type": "audio", "data": encoded}))

async def flush_playback_queue(ws):
    # Barge-in: clear queued audio when the caller interrupts
    await ws.send(json.dumps({"type": "clear"}))

Send at least 500 ms of audio per write to avoid choppy playback on the receiving end. The chunk size must be a multiple of 20 ms, between 20 and 2000 ms; the default is 400 ms. When the caller interrupts, send {"type": "clear"} to flush queued playback immediately.

Step 4: Handle DTMF and call control

DTMF (Dual-Tone Multi-Frequency) tones from the callee arrive over RTP as defined in RFC 4733. LiveKit forwards these tones to your agent. Teler exposes hangup, mute, and cold transfer controls through its call control API. Use these for post-answer call management rather than relying on SIP re-INVITE flows, which add round-trip latency.

The official LiveKit telephony examples repository at livekit-examples/python-agents-examples contains the current reference implementation for telephony agents. Review it alongside this guide for a complete working context.

Teler’s role in the livekit sip stack

Teler targets sub-100ms packet delivery as a design specification, not a measured benchmark. It provisions phone numbers in 50+ countries via API, handles SIP credential and IP-based authentication with IP access control lists, and exposes webhook events for call lifecycle tracking. For the livekit sip path specifically, Teler acts as the SIP trunk that LiveKit’s CreateSIPParticipant dials through. See the full guide on connecting Teler SIP trunking to LiveKit. Your application server sits between Teler’s WebSocket stream and your model stack. See the Teler streaming documentation for the full WebSocket message schema. For cost structure, check current Teler pricing; telephony is billed per channel plus per-minute usage, and AI model costs are paid directly to the model provider.

One honest limitation: there is no documented, officially supported LiveKit-Teler integration path as of September 2026. The integration described here is a developer-built bridge. You own the WebSocket-to-SIP glue, the resampling logic, and the event ordering between LiveKit’s room events and Teler’s stream events. If you need a fully managed telephony path with less custom code, evaluate whether a provider-native bridge fits your requirements before committing to this architecture. For a broader comparison of SIP trunking options, see the Top 9 Best SIP Trunking Providers in the US.

Most teams discover their latency problem is not the model, it is the resampling hop they added between the carrier codec and the STT engine. If your SIP trunk negotiates PCMU at 8 kHz and your STT expects 16 kHz, that conversion runs on every audio chunk for the entire call duration. Measure it before you optimize anything else.

– Subhash Kalluri, Founder & CEO, FreJun

What breaks in production with livekit sip outbound calls?

The failure modes below come from the LiveKit GitHub issue tracker. Each was reported at least once; none is documented as a systemic bug across all deployments.

SymptomRoot causeFixSource
Audio stutter and lag during SIP conversationAgent placed far from inference servers, adding end-to-end delayRun the agent closer to the inference serverlivekit/sip#348, 2025-05-07
Call answered, no audio on either sideNo RTP media flow after SIP handshake; exact upstream cause unresolvedNo fix reported in threadlivekit/sip#424, 2025-07-26
track_subscribed event never fires for outbound callHandler registered after subscription event; agent listening to wrong participantRegister handler before connecting; set waitUntilAnswered=true; select phone participant explicitlylivekit/agents#2157, 2025-04-29
LiveKit does not pick up the callFirewall blocking RTP/media trafficAllow UDP media traffic through the firewalllivekit/sip#370, 2025-05-21
Intro audio plays, then silenceUnresolved in threadNo fix reportedlivekit/agents#3605, 2025-10-08
G722 codec negotiation failureSDP codec selection bugDisable G722 in SDP offer as a workaround; fix SDP selectionlivekit/sip#95, 2024-05-23

The track_subscribed miss catches most teams on their first outbound call. The event fires once, immediately after the SIP participant joins the room. If your handler is registered after that moment, you never receive the remote audio track. The fix is to register the handler before calling createSIPParticipant, then use waitUntilAnswered: true so the participant is fully established before your agent logic runs. For a broader look at debugging voice API pipelines, the guide on how to debug failures in voice API integration pipelines covers the diagnostic approach in detail.

Which architecture fits your livekit sip use case?

ApproachMedia terminates atLatency costOperational burdenLock-in
SIP trunk into LiveKit SIP participant (this guide)LiveKit roomOne SIP hop plus codec negotiationCustom WebSocket-to-SIP glue, resampling if neededTrunk provider only
SIP trunk into separate media server / B2BUAExternal media serverExtra hop, extra bufferingFull RTP path ownership, custom bridgingMedia server vendor
WebRTC-native media gatewayWebRTC sessionGateway conversion overheadSignaling translation, codec adaptationGateway vendor
Provider-native telephony bridgeCarrier SIP edgeReduced custom glueLower custom code, higher provider dependencyStrong provider lock-in

The SIP trunk into LiveKit SIP participant approach is the right choice when your goal is to place standard phone calls with a room-bound voice agent and you want to keep the carrier relationship separate from the media-routing layer. Choose the provider-native bridge instead when your team cannot maintain the WebSocket-to-SIP glue or when the SIP trunk provider already offers a managed agent integration. For teams evaluating the broader voice API landscape, the Top 7 Best Voice APIs for LiveKit in the US covers the provider options in detail.

LiveKit SIP 8 kHz PCMU and PCMA audio resampled up for a higher-bandwidth model stack.

Frequently asked questions

Which audio codecs does LiveKit SIP support, and do they match Teler’s stream format?

LiveKit’s default SIP codecs are PCMU, PCMA, and G722. AMR-WB is available when added in the media config. PCMU and PCMA operate at 8000 Hz; G722 uses 8000 Hz in SDP but transmits 16 kHz audio; AMR-WB operates at 16000 Hz. Teler streams at 8k or 16k, so the 8000 Hz path aligns natively with PCMU and PCMA. If you configure Teler at 16k and LiveKit negotiates PCMU, your application must resample before injecting audio back into the call.

What happens if RTP media does not arrive after the SIP 200 OK?

LiveKit disconnects the call with a media timeout error. The timeout is 30 seconds before the first RTP packet arrives. If at least one packet has arrived, the timeout shortens to 15 seconds. The most common cause is a firewall blocking UDP traffic on the RTP port range. Allow media traffic through before testing; this is documented as a resolved issue in livekit/sip#370.

Should I use SIP trunking or a WebSocket-only path for a LiveKit voice agent?

Use SIP trunking when the destination is a standard PSTN phone number. LiveKit’s SIP participant model requires a SIP trunk to reach the public telephone network; there is no WebSocket-only path to a PSTN number. The WebSocket connection is between your application server and Teler’s streaming layer, not between your server and the phone. SIP handles call setup; RTP carries the media after the handshake.

What does Teler handle, and what must I build myself?

Teler handles carrier connectivity, SIP trunk authentication, phone number provisioning in 50+ countries, real-time WebSocket audio streaming, barge-in via the {"type": "clear"} message, and call control events. You must build the WebSocket-to-SIP event bridge, the STT and TTS integration, any resampling between codec sample rates, and the logic that maps LiveKit room events to Teler stream events. The programmable SIP backbone guide explains the architectural split in more detail.

How does barge-in work when the caller interrupts the agent?

Send {"type": "clear"} over the Teler WebSocket to flush all queued playback immediately. This stops the current TTS audio and lets the caller’s voice through without waiting for the agent to finish speaking. Your application is responsible for detecting the interruption, typically through VAD (Voice Activity Detection) on the inbound audio stream, and triggering the clear message. Teler does not automatically detect barge-in; that logic lives in your server.

What happens to the call if my application server crashes mid-call?

The WebSocket connection to Teler closes, and Teler will terminate the call. LiveKit’s SIP participant remains in the room briefly until the media timeout triggers. There is no automatic reconnect or call handoff documented in the retrieved sources. Build reconnection logic at the application layer and test failover before going to production. The guide on ensuring failover and redundancy while building voice bots covers the patterns in detail.

Does LiveKit SIP support DTMF from the callee?

Yes. DTMF tones are forwarded to the agent via RFC 2833 and RFC 4733 over RTP. LiveKit passes these to the room as events your agent can handle. Teler also exposes DTMF injection for outbound tones, with a configurable tone duration between 40 and 1000 ms, defaulting to 100 ms. The ITU-T G.711 narrowband codec path carries DTMF reliably at 8000 Hz; see ITU-T G.711 for the codec specification.

What you can build now with livekit sip and Teler

With the livekit sip outbound path and Teler’s WebSocket transport, you can place AI-driven phone calls to any PSTN number, stream audio bidirectionally at 8k or 16k, handle barge-in, and control the call lifecycle through a programmable API. The decision that matters most is whether to own the WebSocket-to-SIP bridge yourself or use a provider-native integration. Own it when you need full control over codec selection, resampling, and event ordering. Choose a managed path when the custom glue is not worth the maintenance cost. If your model stack operates above 8 kHz, resolve the resampling question before your first production call; that is where most teams lose time.

About the Author: Subhash Kalluri is the Founder & CEO of FreJun, which he has been building since 2019. With over 8 years in voice communication and SaaS, he works on the problem of getting real-time AI onto live phone calls: raw media streaming, interruption handling, and carrier connectivity. That work became FreJun Teler, FreJun’s programmable voice API for developers building AI phone agents. Connect with him on LinkedIn.

Get started with FreJun today

In this article

Make every voice interaction count

FreJun is a real-time voice platform for automating calls and connecting AI bots.

Popular Articles
Add Voice Bot Conversational AI to Your Web Stack 1 7

Businesses today face increasing pressure to engage customers in real time while optimizing operational efficiency. Voice, as the most immediate...

AssemblyAI applications for coaching: a rep scorecard with talk ratio, questions asked and objections handled

AI Summary: This article describes five ways businesses use AssemblyAI’s Audio Intelligence to turn voice data into insights: sales intelligence...

CPaaS providers Australia: the Australian flag with +61 beside voice, messaging, code and integration API icons.
This guide compares the top 11 CPaaS providers Australia teams can use in 2026, evaluating each on real-time latency, WebSocket...