> ## Documentation Index
> Fetch the complete documentation index at: https://www.vobiz.ai/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# SIP Trunk Setup for LiveKit-Based Voice AI Projects

> How to connect Vobiz SIP trunking to a LiveKit voice AI project. Configure inbound and outbound PSTN calls, SIP dispatch rules, and media routing for LiveKit Agents.

## How do I set up a SIP trunk for a LiveKit-based voice AI project?

LiveKit uses SIP trunking to connect phone calls to LiveKit rooms where AI agents are running. To set up Vobiz as the SIP trunk for a LiveKit project: create a Vobiz SIP trunk, configure a LiveKit SIP Trunk resource pointing to Vobiz's SIP domain, and define a SIP Dispatch Rule to route inbound calls to your AI agent's room. Outbound calls are initiated via the LiveKit API with Vobiz as the carrier.

## Architecture: How LiveKit + Vobiz Works

```
Caller (PSTN) → Vobiz → LiveKit SIP Bridge → LiveKit Room → AI Agent
```

When a call arrives at a Vobiz phone number, Vobiz sends SIP INVITE to LiveKit's SIP server. LiveKit creates a SIP Participant in the specified room. Your AI Agent (running in the same room) receives the audio track, processes it, and publishes its audio response — which LiveKit delivers back to the caller via Vobiz.

For outbound calls, your code uses the LiveKit API to create an outbound SIP Participant, which triggers Vobiz to dial the destination number.

## Setup: Inbound Calls (PSTN → LiveKit Agent)

### Step 1 — Provision a Vobiz Phone Number

```bash theme={null}
curl -X POST https://api.vobiz.ai/api/v1/account/numbers/buy \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"country": "IN", "type": "local"}'
```

### Step 2 — Note Your Vobiz SIP Domain

Your Vobiz SIP trunk domain and credentials are available in the console under **SIP Trunks**. The SIP domain format is:

```
YOUR_ACCOUNT_ID.sip.vobiz.ai
```

### Step 3 — Create a LiveKit SIP Trunk Resource

Using the LiveKit CLI or API, create an Inbound SIP Trunk pointing to Vobiz:

```yaml theme={null}
# livekit-sip-trunk.yaml
id: vobiz-trunk
name: Vobiz Inbound
numbers:
  - "+919XXXXXXXXX"   # your Vobiz DID
auth_username: YOUR_VOBIZ_SIP_USERNAME
auth_password: YOUR_VOBIZ_SIP_PASSWORD
```

```bash theme={null}
lk sip inbound create livekit-sip-trunk.yaml
```

### Step 4 — Create a SIP Dispatch Rule

A Dispatch Rule tells LiveKit which room to route an inbound call to:

```yaml theme={null}
# dispatch-rule.yaml
trunk_ids:
  - vobiz-trunk
rule:
  dispatchRuleIndividual:
    roomPrefix: "call-"
```

```bash theme={null}
lk sip dispatch create dispatch-rule.yaml
```

This routes every inbound call to a unique room (`call-{call_uuid}`). Your AI Agent process should be watching for new rooms matching this prefix.

### Step 5 — Point the Vobiz Number at LiveKit's SIP Server

In the Vobiz console, create an Application and set the Answer URL to point to LiveKit's SIP endpoint. Use SIP application type and enter LiveKit's SIP server URI from your LiveKit project settings.

## Setup: Outbound Calls (LiveKit Agent → PSTN)

Create an Outbound SIP Trunk in LiveKit that uses Vobiz for outbound dialling:

```yaml theme={null}
# outbound-trunk.yaml
name: Vobiz Outbound
address: YOUR_ACCOUNT_ID.sip.vobiz.ai
transport: TLS
numbers:
  - "+919XXXXXXXXX"   # your Vobiz caller ID
auth_username: YOUR_VOBIZ_SIP_USERNAME
auth_password: YOUR_VOBIZ_SIP_PASSWORD
```

```bash theme={null}
lk sip outbound create outbound-trunk.yaml
```

Then initiate outbound calls from your AI agent code:

```python theme={null}
# Python — LiveKit Agents SDK
await ctx.api.sip.create_sip_participant(
    api.CreateSIPParticipantRequest(
        sip_trunk_id="vobiz-outbound-trunk",
        sip_call_to="+919XXXXXXXXX",
        room_name=ctx.room.name,
        participant_name="caller",
    )
)
```

## Audio Configuration

LiveKit uses Opus audio by default. Vobiz transcodes between Opus (LiveKit internal) and G.711 PCMU (PSTN) automatically. For the lowest latency, select the **Mumbai** media region for your Vobiz SIP trunk if your LiveKit infrastructure runs in AWS ap-south-1.

## Frequently Asked Questions

> [accordion] Does Vobiz support LiveKit's SIP Participant feature?
>
> Yes. Vobiz is a standard SIP provider — LiveKit's SIP Bridge connects to Vobiz using standard SIP over TLS with SRTP media. No Vobiz-specific configuration is required beyond providing your SIP trunk URI and credentials to LiveKit.

> [accordion] Can my LiveKit AI agent make and receive calls on the same Vobiz number?
>
> Yes. Configure both an Inbound SIP Trunk (for receiving calls) and an Outbound SIP Trunk (for making calls) in LiveKit, both using the same Vobiz SIP credentials. The same DID number is used as the caller ID for outbound calls.

> [accordion] How do I get Vobiz SIP credentials for LiveKit?
>
> In the Vobiz console, navigate to SIP Trunks > Create Trunk. After creation, the dashboard shows your SIP domain, username, and password. These are the credentials you enter into LiveKit's SIP Trunk configuration.

> [accordion] What is the latency of LiveKit + Vobiz for Indian PSTN calls?
>
> With the Mumbai media PoP on Vobiz and a LiveKit server running in AWS ap-south-1, telephony RTT is typically 40–80ms. LiveKit's internal audio processing adds minimal overhead. See [Low Latency Voice AI](https://www.vobiz.ai/docs/solutions/low-latency-voice-ai.md) for tuning guidance.

***


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.