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./status
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./media-stream
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)
OpenAI Events
Configuration
Environment Variables
Realtime Timeouts
The realtime WebSocket runs with bounded connect / heartbeat / close so a dead upstream cannot hold a Twilio media leg indefinitely:open_timeout=10, ping_interval=20, ping_timeout=20, close_timeout=5, max_size=1 MiB. These are hardcoded, not env-tunable. See Point the realtime endpoint elsewhere for the override flow.
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
Python Usage
Session Configuration
The server sends this session configuration to OpenAI:Related
- Point the realtime endpoint elsewhere - Azure / self-hosted realtime overrides
- CLI - Command-line interface
- Agent - Agent configuration

