Skip to main content
The Call interface connects your agent to voice phone calls. It supports multiple telephony providers (Twilio, Plivo) and three pipeline strategies for different latency/flexibility trade-offs.

Architecture

Three pipeline modes handle the voice-to-text-to-voice conversion differently:

Setup

Install

This installs the websockets dependency needed for real-time audio streaming.

Twilio Setup

  1. Create a Twilio account and get a phone number
  2. Set environment variables:
  1. Configure your Twilio phone number’s webhook:
    • Go to Phone Numbers → Manage → Active Numbers
    • Set A call comes in to your server URL: https://your-domain.com/call/incoming (POST)

Plivo Setup

  1. Create a Plivo account and get a phone number
  2. Set environment variables:
  1. Create a Plivo Application:
    • Go to Voice → Applications → New Application
    • Set Answer URL to: https://your-domain.com/call/incoming (POST)
    • Assign your Plivo phone number to this application
For local development, use ngrok to expose your local server: ngrok http 8000

Quick Start — Managed Mode (Twilio)

The simplest mode. Twilio handles STT and TTS via ConversationRelay — you just provide text.
Call your Twilio number and start talking.

Quick Start — Cascading Mode

Full control over STT and TTS providers. Works with both Twilio and Plivo.

Quick Start — Realtime Mode

Lowest latency using OpenAI’s speech-to-speech Realtime API. Audio flows directly to the model with no intermediate text step.

CallInterface Parameters

Telephony

str
default:"twilio"
Telephony provider: "twilio" or "plivo".
str
required
Phone number to receive calls on (E.164 format, e.g. "+15551234567").
str
Twilio Account SID. Falls back to TWILIO_ACCOUNT_SID env var.
str
Twilio or Plivo auth token. Falls back to TWILIO_AUTH_TOKEN or PLIVO_AUTH_TOKEN env var.
str
Plivo Auth ID. Falls back to PLIVO_AUTH_ID env var.

Pipeline

str
default:"managed"
Voice pipeline mode: "managed", "cascading", or "realtime".
STTProvider
Speech-to-text provider for cascading mode. Required when pipeline="cascading".
TTSProvider
Text-to-speech provider for cascading mode. Required when pipeline="cascading".
RealtimeProvider
Realtime provider for speech-to-speech mode. Required when pipeline="realtime".

Voice Settings

str
Greeting spoken when a call connects.
str
default:"en-US-Standard-A"
Voice name or ID for TTS synthesis.
str
default:"en-US"
BCP-47 language code.
str
default:"any"
When the caller can interrupt: "none", "dtmf", "speech", or "any".
str
default:"medium"
Barge-in sensitivity: "low", "medium", or "high".

Managed Mode Settings

str
default:"deepgram"
STT provider name for managed mode (Twilio ConversationRelay).
str
default:"google"
TTS provider name for managed mode (Twilio ConversationRelay).

Server Paths

str
default:"/call/incoming"
URL path for the incoming call webhook.
str
default:"/call/stream"
URL path for WebSocket audio streams.

Call Settings

int
default:"3600"
Maximum call duration before automatic hangup (1 hour default).

Pipeline Modes

Managed (Twilio Only)

The telephony provider handles STT and TTS natively. Your agent only sees text.
  • Simplest to set up — no STT/TTS provider configuration needed
  • ~500ms latency
  • Limited to Twilio (uses ConversationRelay)
  • Provider-dependent voice/model selection
Plivo does not support managed mode — it has no ConversationRelay equivalent. Use pipeline="cascading" or pipeline="realtime" with Plivo.

Cascading

Raw audio flows through your own STT and TTS providers. Full control over every component.
  • Works with both Twilio and Plivo
  • Pluggable STT (DeepgramSTT) and TTS (CartesiaTTS)
  • Automatic barge-in detection (speech during playback)
  • ~800-1200ms latency

Realtime (OpenAI)

Audio flows directly to OpenAI’s Realtime API for speech-to-speech processing. No intermediate text conversion step.
  • Lowest latency (~200-300ms)
  • Native function calling (tools work without text intermediary)
  • Server-side VAD (voice activity detection)
  • Locked to OpenAI Realtime models (gpt-4o-realtime-preview)

Telephony Providers

Twilio

Supports all three pipeline modes. Uses Media Streams for cascading/realtime and ConversationRelay for managed mode.

Plivo

Supports cascading and realtime modes only. Uses bidirectional Audio Streaming over WebSocket.
Key differences from Twilio:
  • No managed mode (no ConversationRelay equivalent)
  • Supports 16kHz PCM natively (Twilio only supports 8kHz mu-law)
  • Uses HMAC-SHA256 V3 for webhook signatures (Twilio uses HMAC-SHA1)

STT Providers

DeepgramSTT

Real-time streaming transcription via Deepgram’s WebSocket API.

TTS Providers

CartesiaTTS

Ultra-low latency streaming TTS via Cartesia’s WebSocket API (40-90ms TTFB).

Agent with Tools

Give your phone agent capabilities:

Deployment

CallInterface integrates with AgentRuntime, which provides a shared FastAPI server for webhooks and WebSocket connections.
For production:
  • Use a reverse proxy (nginx, Caddy) with TLS termination
  • Point your telephony provider’s webhook to https://your-domain.com/call/incoming
  • The WebSocket endpoint is at wss://your-domain.com/call/stream
  • Set max_call_duration_seconds to prevent runaway calls