Patter: Custom LLM

April 14, 2026 · View on GitHub

Patter

Patter: Custom LLM

Bring your own LLM (Claude, Mistral, Llama, etc.) while Patter handles speech-to-text, text-to-speech, and telephony.

Part of the Patter Voice AI SDK.

Prerequisites

Quick Start

Python

cd python
cp ../.env.example .env   # fill in your keys
pip install -r requirements.txt
python main.py

TypeScript

cd typescript
cp ../.env.example .env   # fill in your keys
npm install
npx tsx main.ts

Environment Variables

VariableRequiredDescription
ANTHROPIC_API_KEYYesAnthropic API key for Claude (or swap with your LLM)
DEEPGRAM_API_KEYYesDeepgram API key for speech-to-text
ELEVENLABS_API_KEYYesElevenLabs API key for text-to-speech
TWILIO_ACCOUNT_SIDYesTwilio account SID
TWILIO_AUTH_TOKENYesTwilio auth token
TWILIO_PHONE_NUMBERYesYour Twilio phone number (E.164)
WEBHOOK_URLNoPublic URL for webhooks (auto-tunneled if omitted)

What This Demonstrates

  • Pipeline mode — separate STT, LLM, and TTS providers for maximum flexibility
  • on_message handler — intercept transcribed speech and generate responses with your own LLM
  • Calling an external LLM API — example uses Anthropic Claude, but swap in any HTTP-based LLM
  • Patter as a voice layer only — Patter manages audio, telephony, and turn-taking while you control the brain

How It Works

  1. Patter receives a phone call and streams audio to Deepgram for transcription
  2. The transcribed text is passed to your on_message callback
  3. Your callback sends the text to any LLM API (Claude in this example) and returns the response
  4. Patter synthesizes the response with ElevenLabs and streams audio back to the caller

Next Steps

License

MIT