| name | retellai-sdk-patterns |
| description | Production-ready Retell AI SDK patterns for voice agent applications.
Use when building production voice agents, implementing retry logic, or establishing patterns.
Trigger with phrases like "retell patterns", "voice agent patterns", "retell best practices".
|
| allowed-tools | Read, Write, Edit |
| version | 1.9.0 |
| license | MIT |
| author | Jeremy Longshore <jeremy@intentsolutions.io> |
| tags | ["saas","retellai","voice","telephony","patterns"] |
| compatibility | Designed for Claude Code, also compatible with Codex and OpenClaw |
Retell AI SDK Patterns
Overview
Production-ready patterns for Retell AI: client singletons, typed agent configurations, call management, and error handling.
Prerequisites
- Completed
retellai-install-auth
retell-sdk installed
Instructions
Step 1: Singleton Client
import Retell from 'retell-sdk';
let _retell: Retell | null = null;
export function getRetellClient(): Retell {
if (!_retell) {
_retell = new Retell({ apiKey: process.env.RETELL_API_KEY! });
}
return _retell;
}
Step 2: Typed Agent Configuration
interface AgentConfig {
name: string;
voiceId: string;
prompt: string;
functions?: FunctionConfig[];
maxCallDurationMs?: number;
endCallAfterSilenceMs?: number;
}
async function createAgent(config: AgentConfig) {
const retell = getRetellClient();
llm = retell..({
: ,
: config.,
: config.,
});
agent = retell..({
: { : , : llm. },
: config.,
: config.,
: config. || ,
: config. || ,
});
{ : agent., : llm. };
}