Skip to main content

API Reference

Complete reference for all types, interfaces, and exports in the getpatter package.

Patter Class

Constructor

ParameterTypeRequiredDescription
carrierTwilio | TelnyxYesCarrier instance. Reads credentials from env vars when arguments are omitted.
phoneNumberstringYesPhone number in E.164 format.
webhookUrlstringConditionalPublic hostname, no scheme. Required unless using tunnel: true in serve().
tunnelCloudflareTunnel | StaticTunnel | booleanNoTunnel directive. true is shorthand for new CloudflareTunnel().
pricingRecord<string, Partial<ProviderPricing>>NoCustom pricing overrides.
persistboolean | stringNoPersist the dashboard’s call history to disk. Defaults to ON since 0.6.2 — pass persist: false to disable. See Configuration.

Instance Methods

MethodSignatureDescription
agent(opts: AgentOptions) => AgentValidates and returns an agent configuration.
serve(opts: ServeOptions) => Promise<void>Starts the embedded server.
call(opts: LocalCallOptions) => Promise<void>Makes an outbound call.
test(opts: ServeOptions) => Promise<void>Starts an interactive terminal test session. See Test Mode.
disconnect() => Promise<void>Stops the tunnel, embedded server, and WebSocket connection.

Carriers

Twilio

Telnyx


Engines

OpenAIRealtime

OpenAIRealtime2

Routes through OpenAIRealtime2Adapter and speaks the GA session.update wire shape (output_modalities, nested audio.{input,output}, session.type = "realtime"). GA session config pins turn_detection.create_response: false and interrupt_response: false so Patter owns response creation and barge-in cancellation. See OpenAIRealtime2.

ElevenLabsConvAI


STT classes

Each class accepts an options object with apiKey?: string and falls back to the provider’s standard env var. See the STT page for full constructor signatures.

TTS classes

Each class accepts an options object with apiKey?: string and falls back to the provider’s standard env var. See the TTS page for full constructor signatures.

LLM classes

Each class accepts an options object with apiKey?: string and falls back to the provider’s standard env var (GoogleLLM prefers GEMINI_API_KEY, falls back to GOOGLE_API_KEY). Pass an instance via phone.agent({ llm }) for pipeline mode. llm is mutually exclusive with onMessage on serve() and is ignored when engine is set. See the LLM page for full constructor signatures.

Tunnels

ClassBehavior
new CloudflareTunnel()Auto-start a Cloudflare Quick Tunnel via the local cloudflared binary.
new StaticTunnel({ hostname })Use an existing public hostname (user-managed tunnel).
tunnel: true on new Patter(...) or phone.serve(...) is shorthand for new CloudflareTunnel().

Tools & Guardrails

Tool

Either handler or webhookUrl must be provided.

Guardrail


Interfaces

AgentOptions

provider is a closed string literal — only 'openai_realtime', 'elevenlabs_convai', or 'pipeline' are valid. It is normally derived from engine / stt + tts and rarely set by hand.

ServeOptions

localRecording enables carrier-neutral SDK-side recording: an interleaved stereo WAV (left = caller, right = agent, PCM16 16 kHz) written incrementally per call. Pass a directory string to choose the output directory. The final path is surfaced as recording_path in the onCallEnd payload. Independent of the carrier-side recording flag. See Local Recording.

LocalCallOptions

ToolDefinition

IncomingMessage

CallControl

CallMetrics / CostBreakdown / LatencyBreakdown / TurnMetrics / ProviderPricing

See Metrics for the full shapes.

Error Classes

All errors extend PatterError, which extends the native Error class.
ClassDescription
PatterErrorBase error class for all SDK errors.
PatterConnectionErrorWebSocket connection failures or disconnection errors.
AuthenticationErrorInvalid or missing API key.
ProvisionErrorFailures when provisioning resources (numbers, agents, calls).
RateLimitErrorProvider returned HTTP 429 on connect/upgrade. Extends PatterConnectionError.

ErrorCode

Every Patter exception carries a stable, machine-readable code property. Branch on the code instead of class-name strings:
Shipped as a const object plus value-union type (not a TS enum) so it is tree-shakeable and compatible with verbatimModuleSyntax. Mirrored byte-for-byte by the Python ErrorCode StrEnum.

Top-level exports

All public classes are imported by name from the package barrel — there are no subpath entry points in getpatter.