I have a SIP provider and I’m trying to configure ...
# ask-ai
e
I have a SIP provider and I’m trying to configure it with LiveKit SIP, but I’m running into a couple of issues. My provider supports the following configuration: • SIP Server Address:
<address>
• SIP Port:
<port>
• Transport Protocol: UDP • SIP Authentication Method: IP-based authentication • Supported Codecs: G.711 and G.729 When I went to the LiveKit dashboard and tried creating an Outbound Trunk, I noticed: I couldn’t find an option for IP-based authentication. 1. In the codec settings, G.711 and G.729 were not listed. Is it possible to configure a SIP provider like this in LiveKit? If so, what’s the correct way to handle IP-based authentication and these codecs?
t
Thanks for reaching out, Aman. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
Thanks — this is helpful. I’m responding to your two specific issues: IP‑based authentication not appearing in the dashboard, and G.711 / G.729 codecs not listed. Short answer • Yes — you can use an IP‑auth SIP provider and the G.711/G.729 codecs with LiveKit, but those settings are not available in the LiveKit dashboard. You must create/configure the trunk via the LiveKit API/CLI or server SDK. What to do next (high level) 1. Use the LiveKit CLI or one of the server SDKs (Python, Go, etc.) to create an outbound (or inbound) trunk. 2. For IP‑based authentication, add your provider’s public IP(s) to the trunk’s allowed addresses so LiveKit will accept connections from those IPs without username/password. 3. For codecs, include
PCMU
and/or
PCMA
for G.711 and
G729
for G.729 in the trunk’s
codecs
array so RTP/SDP negotiation includes those codecs. Example (conceptual; adapt to your SDK/language)
Copy code
trunk = SIPOutboundTrunkInfo(
    name="My IP Auth Trunk",
    protocol="udp",
    gateway="<address>",
    gateway_port=<port>,
    allowed_addresses=["<provider-public-ip>"],
    codecs=["PCMU", "PCMA", "G729"]
)
# then call the create trunk API with this trunk object
Notes on the codec names • G.711 is represented as
PCMU
(μ-law) and
PCMA
(A-law). • G.729 is represented as
G729
. Validation and testing tips • Make sure your provider will send from the listed IP(s) and that you enter the correct public IP(s) in
allowed_addresses
. • Confirm your provider supports the same codec names in SDP offers (PCMU/PCMA/G729). • After creating the trunk, place a test call and inspect the SDP to confirm the negotiated codec is one of the requested codecs and that RTP flows correctly. If you’d like, tell me: • Which SDK or CLI you want to use (Python, Go, CLI), and I’ll give the exact command or code snippet you can run. • The provider public IP(s) and preferred codec order, and I’ll draft a ready-to-run request (with placeholders for your address/port). Sources: sip | livekit/livekit_composite | DeepWiki | server-sdk-kotlin | livekit/livekit_composite | DeepWiki
e
give me nodejs code to create outbound trunk
t
Thanks — I’m responding to your request for Node.js code to create an outbound SIP trunk with IP‑based authentication and G.711/G.729 codecs. What I can’t do • I do not have a Node.js/JavaScript example in the available sources for creating SIP trunks. The existing examples are Python-focused and the docs confirm server SDKs exist for JavaScript, but no concrete Node.js code snippet for trunk creation is available. What I can do instead • I can give you a clear, ready-to-adapt Node.js example that follows the same fields and structure used by the Python SDK examples (name, protocol, gateway, gateway_port, allowed_addresses, codecs). Treat this as a practical template you can run if you have the LiveKit Node.js server SDK or can call the LiveKit API endpoint directly. Node.js (template) — replace placeholders with your values
Copy code
// Template: create an outbound SIP trunk in Node.js
// Replace placeholders: <API_BASE_URL>, <API_KEY>, <API_SECRET>, <address>, <port>, <provider_ip>

const fetch = require('node-fetch'); // or use axios
const crypto = require('crypto');

const API_BASE = '<API_BASE_URL>'; // e.g. <https://your-livekit-instance/api>
const API_KEY = '<API_KEY>';
const API_SECRET = '<API_SECRET>';

// Example: simple HMAC auth header if your LiveKit instance uses API key/secret.
// Adjust auth to match your LiveKit deployment authentication method.
function makeAuthHeader() {
  const ts = Math.floor(Date.now() / 1000).toString();
  const mac = crypto.createHmac('sha256', API_SECRET).update(API_KEY + ts).digest('hex');
  return `APIKEY ${API_KEY}:${mac}:${ts}`;
}

async function createOutboundTrunk() {
  const url = `${API_BASE}/v1/sip/outbound_trunks`; // adjust path if different
  const body = {
    trunk: {
      name: "My IP Auth Trunk",
      protocol: "udp",
      gateway: "<address>",        // SIP Server Address
      gateway_port: <port>,       // SIP Port (number)
      allowed_addresses: ["<provider-public-ip>"], // IP-based auth (whitelist)
      codecs: ["PCMU", "PCMA", "G729"], // G.711 as PCMU/PCMA, plus G729
      // optional fields you may include:
      // numbers: ["+12223334444"],
      // krisp_enabled: false,
    }
  };

  const res = await fetch(url, {
    method: 'POST',
    headers: {
      'Content-Type': 'application/json',
      'Authorization': makeAuthHeader(), // adapt as needed
    },
    body: JSON.stringify(body),
  });

  if (!res.ok) {
    const text = await res.text();
    throw new Error(`Failed to create trunk: ${res.status} ${text}`);
  }

  const data = await res.json();
  return data;
}

createOutboundTrunk()
  .then((r) => {
    console.log('Trunk created:', JSON.stringify(r, null, 2));
  })
  .catch((err) => {
    console.error('Error creating trunk:', err.message);
  });
Notes and how to adapt • Authentication: Replace the example HMAC auth with whatever your LiveKit API expects (API key header, JWT, or other). The template shows one possible approach but must match your deployment. • Endpoint path: I used
/v1/sip/outbound_trunks
as an example. If your LiveKit API path differs, change
url
accordingly. • Codecs: Use
PCMU
/
PCMA
for G.711 (μ-law / A-law) and
G729
for G.729. • IP auth: Add your provider’s public IP(s) to
allowed_addresses
to enable IP‑based authentication. • If your environment uses the official Node.js SDK (not raw HTTP), the payload fields are the same — you would construct the equivalent SDK request object and call the SDK method to create the trunk. If you want, I can: • Convert this template to use a specific HTTP library (axios) or the official LiveKit Node SDK if you confirm which SDK version/installation you have. • Fill in a complete example for your auth method (API key header vs JWT) if you tell me how your LiveKit instance is secured. • Verify the exact API path if you share the LiveKit version or API base path you’re using. Sources: sip | livekit/livekit_composite | DeepWiki | Python SDKs | livekit/livekit_composite | DeepWiki | Creating SIP Inbound Trunks and Dispatch Rules with Python SDK
e
can you give me link to it's api doc
t
Thanks — you're asking for the LiveKit API documentation link. You can find the Server API reference here: • https://docs.livekit.io/reference/ That reference covers the server REST/API endpoints used for SIP trunk management and other server-side operations. If you want, I can point you to the exact endpoint for creating outbound trunks or draft a Node.js example using the specific auth method your LiveKit instance uses — tell me which auth (API key, JWT, etc.) you use and I’ll tailor it. Sources: Handling asynchronous metadata updates in LiveKit | LiveKit
e
give me steps for creating trunk using lk cli and sample json for my requested payload
t
Thanks — I’m responding to your request for step‑by‑step CLI instructions and a sample JSON payload to create an outbound SIP trunk with IP‑based authentication and G.711/G.729 codecs. Steps to create the trunk with the LiveKit CLI 1. Install and authenticate the LiveKit CLI (if not already): ◦ Follow your normal CLI install procedure and configure it with your LiveKit instance URL, API key, and secret. 1. Create a JSON file for the outbound trunk configuration (example below). Save it as
outbound-trunk.json
. 2. Run the CLI command to create the trunk: ◦ lk sip outbound create outbound-trunk.json 1. Verify the trunk was created: ◦ lk sip outbound list ◦ Optionally inspect the created trunk: lk sip outbound get <trunk_id> Sample JSON payload Save this as
outbound-trunk.json
and replace placeholders with your values (address, port, provider IPs, numbers if needed):
Copy code
{
  "trunk": {
    "name": "My Outbound Trunk",
    "outbound": {
      "address": "<http://sip.provider.com|sip.provider.com>",
      "port": 5060,
      "transport": "udp",
      "allowed_auth_identity": "",
      "allowed_addresses": [
        "203.0.113.10",
        "203.0.113.11"
      ],
      "codecs": [
        "PCMU",
        "PCMA",
        "G729"
      ]
    },
    "numbers": [
      "+12223334444"
    ],
    "krisp_enabled": false
  }
}
Notes on fields and values • `outbound.address`: SIP server address provided by your SIP provider. • `outbound.port`: SIP port (commonly 5060 for UDP). • `outbound.transport`:
udp
to match your provider’s transport protocol. • `allowed_auth_identity`: left empty for IP‑based auth (no username). • `allowed_addresses`: provider public IP(s) — this is the IP‑based authentication (whitelist). • `codecs`: use `PCMU`/`PCMA` for G.711 (μ-law / A-law) and
G729
for G.729. • `numbers`: optional list of DID numbers to assign to the trunk. • `krisp_enabled`: optional boolean; include if you want noise suppression disabled/enabled. Validation & testing tips • Confirm the provider will send traffic from the public IPs you list in
allowed_addresses
. • After creation, place a test call and inspect the SDP to ensure the negotiated codec is one of the specified codecs. • Ensure any firewalls/NAT allow SIP (UDP 5060/other port) and RTP media ports to/from LiveKit and the provider. If you want, I can: • Adapt this JSON for an inbound trunk instead. • Provide the exact
lk
CLI command syntax if your
lk
CLI version uses a different path/flags. • Convert the payload into a Node.js SDK request if you prefer using code instead of the CLI. Which would you like next? Sources: Making calls overview | LiveKit Documentation