DOCUMENTATION

sip_realtime_ai

Standalone SIP-to-AI gateway — configuration, routing, audio and providers.

GETTING STARTED

Overview

sip_realtime_ai is a standalone Linux SIP-to-realtime-AI gateway. It accepts SIP calls, establishes RTP audio sessions, selects an AI profile from the SIP Request-URI user and exchanges audio with the selected provider.

SIP Endpoint / PBXsip_realtime_aiRealtime AI Provider
Supported integrations: OpenAI, Google Gemini, ElevenLabs and Azure Voice Live. FreeSWITCH is not required.
GETTING STARTED

Installation

Officially supported platform: Debian 13 (Trixie), amd64. The gateway is distributed as a Debian package and runs independently of FreeSWITCH. Builds for other Linux distributions may be available upon request.

TERMINALInstall the Debian package
sudo apt install ./sip-realtime-ai_*.deb

The package installs a sample XML gateway configuration and an OpenAI session JSON example in the following locations:

FILESConfiguration layout
/etc/sip_realtime_ai/
├── sip_realtime_ai.conf
└── realtime_ai/
    └── sales.json

The main .conf file contains XML. Update the gateway settings and AI profile credentials, then customize the OpenAI session settings:

TERMINALEdit configuration
sudo nano /etc/sip_realtime_ai/sip_realtime_ai.conf
sudo nano /etc/sip_realtime_ai/realtime_ai/sales.json

Additional provider profiles can reference their own JSON files placed in /etc/sip_realtime_ai/realtime_ai/. The package includes the OpenAI example; other provider configurations can be added as needed.

Networking: permit inbound SIP signaling on the configured UDP port and RTP traffic on the configured UDP port range. If the service is behind NAT or a VM firewall, configure the network accordingly.
GETTING STARTED

Configuration

The gateway uses an XML configuration with three top-level sections: <license>, <settings> and <profiles>. The example below reflects the tested local configuration; replace the credentials before deployment. The license example is for trial/commercial use; Community Edition needs no license.

XMLsip_realtime_ai.conf
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
  <license>
    <param name="product" value="sip_realtime_ai"/>
    <param name="type" value="trial"/>
    <param name="issued_to" value="YOUR_COMPANY"/>
    <param name="expires_at" value="YOUR_EXPIRY"/>
    <param name="sig" value="YOUR_LICENSE_SIGNATURE"/>
  </license>
  <settings>
    <param name="sip-bind" value="127.0.0.1"/>
    <param name="sip-port" value="5070"/>
    <param name="rtp-bind" value="127.0.0.1"/>
    <param name="rtp-port-start" value="10000"/>
    <param name="rtp-port-end" value="19998"/>
  </settings>
  <profiles>
    <profile name="sales">
      <param name="provider" value="openai"/>
      <param name="api-key" value="YOUR_API_KEY"/>
      <param name="model" value="gpt-realtime-2.1"/>
      <param name="config" value="sales.json"/>
    </profile>
  </profiles>
</configuration>
GETTING STARTED

Licensing

Community Edition: free for up to 10 concurrent channels, with no license required. Trial and commercial licenses are available for deployments that need higher capacity.

Trial and commercial licenses use the <license> section. The product value is sip_realtime_ai; the license supplies the remaining signed fields.

TERMINALLicense management
sip_realtime_ai license status
sip_realtime_ai license request

license status displays license information; license request prepares a request for a trial or commercial license. Community Edition users do not need to run either command.

Do not publish license signatures or provider API keys.

SIP & MEDIA

SIP / RTP Settings

The <settings> section defines local SIP and RTP interfaces and ports. The values below are from the local test configuration, not recommended public bind addresses.

XMLsip_realtime_ai.conf — settings
<settings>
  <param name="sip-bind" value="127.0.0.1"/>
  <param name="sip-port" value="5070"/>
  <param name="rtp-bind" value="127.0.0.1"/>
  <param name="rtp-port-start" value="10000"/>
  <param name="rtp-port-end" value="19998"/>
</settings>

In this configuration, SIP signaling uses UDP port 5070 and RTP uses UDP ports 10000–19998. Binding to 127.0.0.1 limits traffic to the local host; remote endpoints require an appropriate reachable interface and firewall rules.

Transport: SIP signaling over UDP; media supports plain RTP (RTP/AVP) and SDES-SRTP (RTP/SAVP) with AES_CM_128_HMAC_SHA1_80. DTLS-SRTP and SIP over TLS are not part of the documented implementation.
SIP & MEDIA

SIP Routing

The gateway selects a named AI profile using the user portion of the SIP Request-URI. For example, a call addressed to sip:sales@gateway.example selects the sales profile.

→ INVITE sip:sales@gateway.example SIP/2.0
Profile selected: sales

Each destination used for routing must have a corresponding profile configured under <profiles>. The example hostname is illustrative, not a required gateway hostname.

SIP & MEDIA

SDES-SRTP

The gateway supports SDES-SRTP for encrypted RTP media. Key material is negotiated in the SIP/SDP exchange using an a=crypto attribute with an inline: key. The supported crypto suite is AES_CM_128_HMAC_SHA1_80 (AES-128 counter-mode encryption with an 80-bit HMAC-SHA1 authentication tag).

SDPSDES-SRTP offer — illustrative
m=audio 10000 RTP/SAVP 0 8
 a=rtpmap:0 PCMU/8000
 a=rtpmap:8 PCMA/8000
 a=crypto:1 AES_CM_128_HMAC_SHA1_80 inline:<BASE64_MASTER_KEY_AND_SALT>

For an accepted secure-media offer, the gateway generates an RTP/SAVP answer with the selected a=crypto tag, suite and its own inline key material. Both PCMU and PCMA can be offered as RTP payload formats, subject to codec negotiation.

Compatibility: SDES-SRTP is not DTLS-SRTP. The current SDP parser does not support DTLS-SRTP or optional SDES key lifetime/MKI parameters. Because SDES conveys keys in SDP, use a trusted signaling path; SIP over TLS is not claimed as supported by this gateway.
SIP & MEDIA

Audio Codecs

The gateway RTP media path supports PCMU (G.711 μ-law) and PCMA (G.711 A-law) for 8 kHz telephony audio. Provider-side formats are configured separately and may differ from the SIP media codec.

SIP RTP · PCMU / PCMADecode / ResampleAI Audio

Codec support on a given call also depends on the endpoint SDP offer and the codec selected during negotiation.

SIP & MEDIA

Audio Processing

Caller audio is streamed to the selected realtime AI provider, while AI-generated speech is returned over RTP. The gateway handles media conversion and resampling independently in each direction when the provider requires a different audio format or sample rate. SIP-side PCMU/PCMA and provider-side audio formats do not need to match.

For example, the tested OpenAI profile uses 24 kHz PCM audio while the SIP side uses G.711 telephony media. The tested Azure profile receives G.711 μ-law at 8 kHz and sends PCM16 at 8 kHz. Provider-specific turn detection and response interruption settings remain in the provider-native JSON configuration. Barge-in behavior depends on provider support and session settings.

SIP & MEDIA

SIP INFO Commands

During an active SIP call, send an in-dialog INFO request with Content-Type: application/json to interact with the selected AI provider.

send_text

Send a text message to the active AI session. The gateway translates the message into the selected provider's native protocol.

JSONSIP INFO body
{
  "command": "send_text",
  "text": "Hello from SIP INFO!"
}
update

Forward a provider-native JSON object to the active AI session. The data object is passed through without translating provider-specific fields. Supported updates depend on the provider.

JSONOpenAI example — SIP INFO body
{
  "command": "update",
  "data": {
    "type": "session.update",
    "session": {
      "instructions": "Always respond in English."
    }
  }
}
Note: A successful SIP INFO response indicates that the gateway accepted the command; the AI provider may still reject an unsupported update. The session.update event above is specific to OpenAI and must not be copied unchanged to other providers.
PROVIDERS

Profiles

Define one or more named profiles in the <profiles> section. A profile selects the provider, API key and provider-specific model or configuration. Profiles can be named according to their SIP destination, such as sales or support.

Provider JSON files contain native provider session settings. They are not interchangeable across providers. The gateway forwards provider-specific session configuration without introducing a proprietary schema for provider options. Supported native options may include voices, instructions, VAD, interruption behavior, audio formats and tool/function declarations. Tool execution and external integrations still require the corresponding provider and application-side implementation; declaring a function alone does not implement it.

PROVIDERS

OpenAI

Configure an OpenAI gateway profile with your API key, realtime model and a provider-native JSON configuration file. The tested example uses PCM16 at 24 kHz in both directions.

XML OpenAI gateway profile
<profile name="sales">
    <param name="provider" value="openai"/>
    <param name="api-key" value="YOUR_API_KEY"/>
    <param name="config" value="sales.json"/>
    <param name="model" value="gpt-realtime-2.1"/>
</profile>
Place the referenced provider-native JSON file in /etc/sip_realtime_ai/realtime_ai/.
JSON sales.json
{
  "type": "session.update",
  "session": {
    "type": "realtime",
    "instructions": "You are a helpful voice assistant.",
    "output_modalities": [
      "audio"
    ],
    "audio": {
      "input": {
        "format": {
          "type": "audio/pcm",
          "rate": 24000
        },
        "turn_detection": {
          "type": "server_vad",
          "threshold": 0.7,
          "prefix_padding_ms": 300,
          "silence_duration_ms": 500,
          "create_response": true,
          "interrupt_response": true
        }
      },
      "output": {
        "format": {
          "type": "audio/pcm",
          "rate": 24000
        },
        "voice": "marin"
      }
    }
  }
}
PROVIDERS

Google Gemini

Gemini profiles use an API key and a provider-native JSON configuration file.

XML Google Gemini gateway profile
<profile name="support">
    <param name="provider" value="gemini"/>
    <param name="api-key" value="YOUR_API_KEY"/>
    <param name="config" value="support.json"/>
</profile>
Place the referenced provider-native JSON file in /etc/sip_realtime_ai/realtime_ai/.
JSON support.json
{
  "setup": {
    "model": "models/gemini-3.8-live",
    "generationConfig": {
      "responseModalities": [
        "AUDIO"
      ]
    },
    "tools": [
      {
        "functionDeclarations": [
          {
            "name": "get_current_time",
            "description": "Get the current local time.",
            "parameters": {
              "type": "OBJECT",
              "properties": {}
            }
          }
        ]
      }
    ]
  }
}
This tested example includes a native function declaration for get_current_time. Implementing and returning the function result requires application-side handling.
PROVIDERS

ElevenLabs

ElevenLabs uses an existing Agent configuration. Specify the ElevenLabs Agent ID through the profile's model parameter.

XML ElevenLabs gateway profile
<profile name="elevenlabs">
    <param name="provider" value="elevenlabs"/>
    <param name="api-key" value="YOUR_API_KEY"/>
    <param name="model" value="YOUR_AGENT_ID"/>
</profile>
ElevenLabs: the model parameter contains the ElevenLabs Agent ID. The agent itself is configured in ElevenLabs.
PROVIDERS

Azure Voice Live

Azure Voice Live requires an Azure endpoint in addition to the API key, model and provider-native JSON session configuration.

XML Azure Voice Live gateway profile
<profile name="azure">
    <param name="provider" value="azure"/>
    <param name="api-key" value="YOUR_API_KEY"/>
    <param name="config" value="azure.json"/>
    <param name="model" value="gpt-realtime"/>
    <param name="endpoint" value="https://your-resource.services.ai.azure.com"/>
</profile>
Azure: endpoint identifies the Azure resource used by the Voice Live connection.
JSON azure.json
{
  "type": "session.update",
  "session": {
    "modalities": [
      "text",
      "audio"
    ],
    "voice": {
      "type": "openai",
      "name": "alloy"
    },
    "instructions": "You are a helpful voice assistant. Respond briefly and naturally.",
    "input_audio_format": "g711_ulaw",
    "output_audio_format": "pcm16_8000hz",
    "input_audio_sampling_rate": 8000,
    "input_audio_transcription": {
      "model": "gpt-4o-mini-transcribe"
    },
    "turn_detection": {
      "type": "azure_semantic_vad",
      "threshold": 0.5,
      "prefix_padding_ms": 420,
      "silence_duration_ms": 500
    }
  }
}
This tested example uses G.711 μ-law at 8 kHz for provider input and PCM16 at 8 kHz for provider output. The gateway converts SIP-side media as needed.
HELP

Troubleshooting

Gateway does not start

Check the XML syntax and required <license> section. If licensing fails, review the license type, expiration and signature supplied for this gateway.

SIP call cannot reach the gateway

Verify sip-bind, sip-port, local firewall and SIP routing. A service bound to 127.0.0.1 cannot receive direct traffic from another machine.

Call arrives but the wrong AI profile is selected

Check the user part of the SIP Request-URI and confirm a matching <profile name="..."> exists.

Call connects but there is no audio

Verify the negotiated PCMU/PCMA codec, RTP port range, firewall/NAT path and the provider's native input/output audio format.

Provider connection fails

Verify the provider API key, model or Agent ID, endpoint where required, and the provider-native JSON configuration. Review gateway logs for the reported failure.