Connect to OpenAI

Connect a Callr Phone Number to an OpenAI Realtime AI Agent

📘

This guide explains how to connect a Callr phone number to an OpenAI Realtime AI agent using SIP

  • Callr handles telephony worldwide: phone numbers, carrier connectivity, call routing, SIP, reliability, compliance.
  • OpenAI handles real-time AI: speech recognition, reasoning, tool use, and speech synthesis.
➡️

The result: anyone can call your Callr number, and the call is handled live by your OpenAI AI agent.


🏗️ Architecture Overview

  1. A user dials your Callr phone number.
  2. Callr receives the Inbound Call.
  3. A Callr scenario uses dial@v1 to connect the call to an OpenAI Realtime SIP endpoint.
  4. OpenAI answers the SIP call and runs your real-time AI agent.
  5. Audio flows bidirectionally between the caller and the AI.

⚙️ Prerequisites

Before starting, make sure you have:

  • A Callr account
  • A purchased Callr phone number
  • A Callr Actions scenario
  • An OpenAI project with Realtime API enabled
  • Your OpenAI SIP URI (from the OpenAI dashboard)

OpenAI provides a SIP endpoint in this format:

sip:<project-id>@sip.api.openai.com;transport=tls

🤖 Step 1 – Configure Your OpenAI Realtime Agent

In OpenAI:

  1. Create or configure a Realtime agent.
  2. Enable SIP connectivity.
  3. Copy your SIP URI:
sip:<project-id>@sip.api.openai.com;transport=tls

OpenAI handles:

  • Speech-to-text
  • LLM reasoning
  • Tool calling
  • Text-to-speech
  • Session state

Callr does not process AI logic - it transports the audio stream securely over SIP/TLS.


⚡ Step 2 – Create a Callr Scenario

Create a Callr Actions scenario that dials the OpenAI SIP endpoint when your number receives a call.

Example:

description: Route inbound call to OpenAI Realtime AI

compat:
  version: "2025-09-01"

defaults:
  autoAnswer: false

branches:
  inbound-call:
    actions:
      - action: dial@v1
        params:
          targets:
            - number: sip:<project-id>@sip.api.openai.com;transport=tls
              timeout: 60

How it works

  • inbound-call is triggered when someone calls your Callr number.
  • dial@v1 creates an outbound SIP call.
  • The target is the OpenAI Realtime SIP endpoint.
  • transport=tls ensures encrypted SIP signaling.

Callr handles:

  • PSTN termination
  • SIP negotiation
  • Secure transport (TLS)
  • Media bridging
  • Global carrier reliability

OpenAI handles:

  • Real-time audio processing
  • AI conversation
  • Speech generation

🔗 Step 3 – Attach the Scenario to Your Phone Number

In the Callr dashboard:

  1. Go to your phone numbers.
  2. Select the number.
  3. Attach the scenario you created.

Your number is now connected to the OpenAI AI agent.


🧩 Optional – Add Fallback or Business Logic

Because routing happens inside Callr, you can add:

  • Time-based routing (business hours vs after hours)
  • Failover to a human agent if SIP fails
  • Geographic routing
  • Call recording (if compliant in your jurisdiction)
  • Pre-call IVR before sending to AI

Example with fallback and call recording:

branches:
  inbound-call:
    actions:
      - action: startRecording@v1

      - action: dial@v1
        params:
          targets:
            - number: sip:<project-id>@sip.api.openai.com;transport=tls
              timeout: 20
            # this PSTN number will be called if OpenAI fails to answer the call
            - number: '+33199001234' 
              timeout: 60
        result: $dial

      - if: '!$dial.ok'
        action: say@v2
        params:
          what: "Sorry, we are unable to connect you at the moment."

🚀Why This Architecture Works Well

Callr
  • Own and manage phone numbers worldwide
  • Carrier-grade voice quality
  • Global PSTN connectivity
  • High availability
  • Regulatory compliance
OpenAI
  • Advanced speech models
  • Real-time reasoning
  • Tool execution
  • Natural voice synthesis
  • Stateful AI agents
👍

Each platform does what it does best.