Skip to main content
GET
Voice Call API

Voice Call API

The Voice Call API provides Twilio voice integration with OpenAI’s Realtime API for voice-based AI interactions.

Binding

praisonai call binds to 127.0.0.1:8090 by default. Inside a container or VM, use --host 0.0.0.0 so the server is reachable from outside the container boundary — see Binding & Network Access for details. Always pair an exposed port with CALL_SERVER_TOKEN.

Base URL

Endpoints

Status Page

Check if the server is running.
GET
/status
Returns HTML status page
Response

Incoming Call Handler

Handle incoming Twilio calls and return TwiML response.
GET/POST
/
Twilio webhook for incoming calls
Response (TwiML)

Media Stream WebSocket

WebSocket endpoint for real-time audio streaming between Twilio and OpenAI.
WebSocket
/media-stream
WebSocket for audio streaming
Connection Flow
  1. Twilio connects to WebSocket
  2. Server connects to OpenAI Realtime API
  3. Audio streams bidirectionally:
    • Twilio → Server → OpenAI (user speech)
    • OpenAI → Server → Twilio (AI response)
Twilio Events OpenAI Events

Configuration

Environment Variables

Custom Tools

Create a tools.py file in the working directory:

Usage Example

Start Server

Twilio Configuration

  1. Get your public URL (ngrok or deployed)
  2. In Twilio Console:
    • Go to Phone Numbers → Your Number
    • Set Voice webhook to: https://your-url.ngrok.io/
    • Method: POST

Python Usage

Session Configuration

The server sends this session configuration to OpenAI:
  • CLI - Command-line interface
  • Agent - Agent configuration