Skip to main content

Engines

An engine is an end-to-end speech-to-speech runtime. Pass an engine instance to phone.agent({ engine }) and Patter wires the audio stream straight through to the provider — no separate STT or TTS is needed. Patter ships with two engine classes today: Each class ships as both a flat alias (import { OpenAIRealtime } from "getpatter") and a namespaced class (import * as openai from "getpatter/engines/openai"new openai.Realtime()). They are equivalent. If you need full control over STT, LLM, and TTS independently, use pipeline mode instead and omit engine.

OpenAIRealtime

OpenAI’s Realtime API — the lowest-latency option.
// npx tsx example.ts
import { Patter, Twilio, OpenAIRealtime } from "getpatter";

const phone = new Patter({ carrier: new Twilio(), phoneNumber: "+15550001234" });

const agent = phone.agent({
  engine: new OpenAIRealtime({ voice: "alloy" }),           // OPENAI_API_KEY from env
  systemPrompt: "You are a helpful assistant.",
  firstMessage: "Hello!",
});

await phone.serve({ agent });
ParameterTypeDefaultDescription
apiKeystringOpenAI API key. Reads from OPENAI_API_KEY when omitted.
voicestring"alloy"One of "alloy", "ash", "ballad", "coral", "echo", "sage", "shimmer", "verse".
modelstring"gpt-4o-mini-realtime-preview"OpenAI Realtime model ID.
Namespaced form:
import * as openai from "getpatter/engines/openai";

const engine = new openai.Realtime();                 // reads OPENAI_API_KEY
const engine = new openai.Realtime({ voice: "alloy" });

ElevenLabsConvAI

ElevenLabs Conversational AI — premium voice quality using a managed agent configured in the ElevenLabs dashboard.
// npx tsx example.ts
import { Patter, Twilio, ElevenLabsConvAI } from "getpatter";

const phone = new Patter({ carrier: new Twilio(), phoneNumber: "+15550001234" });

const agent = phone.agent({
  engine: new ElevenLabsConvAI({ agentId: "agent_abc123" }),   // ELEVENLABS_API_KEY from env
  systemPrompt: "You are a warm and friendly concierge.",
});

await phone.serve({ agent });
ParameterTypeDefaultDescription
apiKeystringElevenLabs API key. Reads from ELEVENLABS_API_KEY when omitted.
agentIdstringElevenLabs agent ID (from the ConvAI dashboard). Reads from ELEVENLABS_AGENT_ID when omitted.
voicestringOptional override for the agent’s default voice ID.
Namespaced form:
import * as elevenlabs from "getpatter/engines/elevenlabs";

const engine = new elevenlabs.ConvAI();               // reads env
const engine = new elevenlabs.ConvAI({ agentId: "agent_abc123", voice: "rachel" });

What’s Next

LLM

Compare engine mode with pipeline mode.

STT

STT for pipeline mode.

TTS

TTS for pipeline mode.