Voice Call API
API Endpoints
Voice Call API
Twilio voice integration with OpenAI Realtime API
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.Returns HTML status page
Incoming Call Handler
Handle incoming Twilio calls and return TwiML response.Twilio webhook for incoming calls
Media Stream WebSocket
WebSocket endpoint for real-time audio streaming between Twilio and OpenAI.WebSocket for audio streaming
- Twilio connects to WebSocket
- Server connects to OpenAI Realtime API
- Audio streams bidirectionally:
- Twilio → Server → OpenAI (user speech)
- OpenAI → Server → Twilio (AI response)
| Event | Description |
|---|---|
start | Stream started |
media | Audio data chunk |
stop | Stream ended |
| Event | Description |
|---|---|
session.created | Session initialized |
session.updated | Session config updated |
input_audio_buffer.speech_started | User started speaking |
input_audio_buffer.speech_stopped | User stopped speaking |
response.audio.delta | AI audio response chunk |
response.done | AI response complete |
Configuration
Environment Variables
| Variable | Required | Default | Description |
|---|---|---|---|
OPENAI_API_KEY | Yes | - | OpenAI API key with Realtime access |
PORT | No | 8090 | Server port |
NGROK_AUTH_TOKEN | No | - | ngrok token for public URL |
PUBLIC | No | false | Enable public URL via ngrok |
Custom Tools
Create atools.py file in the working directory:
Usage Example
Start Server
Twilio Configuration
- Get your public URL (ngrok or deployed)
- In Twilio Console:
- Go to Phone Numbers → Your Number
- Set Voice webhook to:
https://your-url.ngrok.io/ - Method: POST

