RE

retellai-sdk-patterns

Apply best practices for Retell AI agent configuration, call management, and client singleton design.

Install

mkdir -p .claude/skills/retellai-sdk-patterns && curl -L -o skill.zip "https://agentskills.codes/api/skills/download/8716" && unzip -o skill.zip -d .claude/skills/retellai-sdk-patterns && rm skill.zip

Installs to .claude/skills/retellai-sdk-patterns

Activation

This is the description your AI agent reads to decide when to run this skill — the better it matches your request, the more reliably it fires.

Production-ready Retell AI SDK patterns for voice agent applications.
69 charsno explicit “when” trigger
Intermediate

Key capabilities

  • Create a singleton client for the Retell AI SDK
  • Define and create typed agent configurations
  • Implement retry logic for creating phone calls
  • Manage concurrent call campaigns with rate limiting
  • Configure LLM and voice settings for Retell agents
  • Handle call lifecycle events

How it works

This skill provides patterns for initializing a Retell AI client, creating typed agent configurations, and managing phone calls with retry logic and concurrent campaign execution.

Inputs & outputs

You give it
Retell API key, agent configuration (name, voiceId, prompt), phone numbers, concurrency settings
You get back
Retell client instance, created agent IDs, call IDs, or call campaign results

When to use retellai-sdk-patterns

  • Initialize Retell API clients
  • Define typed agent configurations
  • Manage voice agent call parameters
  • Handle call lifecycle events

About this skill

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();

  const llm = await retell.llm.create({
    model: 'gpt-4o',
    general_prompt: config.prompt,
    functions: config.functions,
  });

  const agent = await retell.agent.create({
    response_engine: { type: 'retell-llm', llm_id: llm.llm_id },
    voice_id: config.voiceId,
    agent_name: config.name,
    max_call_duration_ms: config.maxCallDurationMs || 300000,
    end_call_after_silence_ms: config.endCallAfterSilenceMs || 10000,
  });

  return { agentId: agent.agent_id, llmId: llm.llm_id };
}

Step 3: Call Manager with Retry

async function makeCallWithRetry(
  fromNumber: string, toNumber: string, agentId: string, maxRetries = 2
) {
  const retell = getRetellClient();
  for (let attempt = 0; attempt <= maxRetries; attempt++) {
    try {
      const call = await retell.call.createPhoneCall({
        from_number: fromNumber,
        to_number: toNumber,
        override_agent_id: agentId,
      });
      return call;
    } catch (err: any) {
      if (attempt === maxRetries || err.status < 500) throw err;
      await new Promise(r => setTimeout(r, 2000 * (attempt + 1)));
    }
  }
}

Step 4: Batch Call Campaign

async function runCallCampaign(
  numbers: string[], agentId: string, concurrency = 3, delayMs = 2000
) {
  const results: Array<{ number: string; callId?: string; error?: string }> = [];
  const queue = [...numbers];
  const active = new Set<Promise<void>>();

  while (queue.length > 0 || active.size > 0) {
    while (active.size < concurrency && queue.length > 0) {
      const number = queue.shift()!;
      const p = (async () => {
        try {
          const call = await makeCallWithRetry(process.env.RETELL_PHONE_NUMBER!, number, agentId);
          results.push({ number, callId: call.call_id });
        } catch (err: any) {
          results.push({ number, error: err.message });
        }
        await new Promise(r => setTimeout(r, delayMs));
      })();
      active.add(p);
      p.finally(() => active.delete(p));
    }
    if (active.size > 0) await Promise.race(active);
  }
  return results;
}

Output

  • Singleton Retell client
  • Typed agent creation with LLM configuration
  • Retry logic for call creation
  • Concurrent call campaign manager

Error Handling

PatternUse CaseBenefit
SingletonAll SDK callsOne client instance
Typed configAgent creationType safety, defaults
Retry wrapperCall failuresAutomatic recovery
Campaign managerOutbound callsRate-limited concurrency

Resources

Next Steps

Apply in retellai-core-workflow-a for agent building.

When not to use it

  • When not building voice agents with Retell AI
  • When not needing to manage Retell AI call campaigns
  • When not requiring retry logic for Retell AI API calls

Prerequisites

Completed `retellai-install-auth``retell-sdk` installed

Limitations

  • The patterns are specific to the Retell AI SDK
  • Retry logic for calls is limited to a maximum of 2 retries
  • Call campaign concurrency is configurable but subject to Retell AI rate limits

How it compares

This skill offers structured patterns for building production-ready Retell AI voice agents, including client management, typed configurations, and reliable call handling, which simplifies complex voice agent deployments.

Compared to similar skills

retellai-sdk-patterns side by side with the closest alternatives in the catalog.

SkillInstallsUpdatedSafetyDifficulty
retellai-sdk-patterns (this skill)027dReviewIntermediate
telegram-bot-builder1066moReviewIntermediate
reddit-api34moReviewIntermediate
juicebox-install-auth227dReviewBeginner

Try saying

Example prompts that trigger this skill in your AI assistant.

More by jeremylongshore

View all by jeremylongshore

analyzing-logs

jeremylongshore

Analyze application logs to detect performance issues, identify error patterns, and improve stability by extracting key insights.

14123

ollama-setup

jeremylongshore

Configure auto-configure Ollama when user needs local LLM deployment, free AI alternatives, or wants to eliminate hosted API costs. Trigger phrases: "install ollama", "local AI", "free LLM", "self-hosted AI", "replace OpenAI", "no API costs". Use when appropriate context detected. Trigger with relevant phrases based on skill purpose.

1167

backtesting-trading-strategies

jeremylongshore

Backtest crypto and traditional trading strategies against historical data. Calculates performance metrics (Sharpe, Sortino, max drawdown), generates equity curves, and optimizes strategy parameters. Use when user wants to test a trading strategy, validate signals, or compare approaches. Trigger with phrases like "backtest strategy", "test trading strategy", "historical performance", "simulate trades", "optimize parameters", or "validate signals".

1071

generating-database-seed-data

jeremylongshore

Process this skill enables AI assistant to generate realistic test data and database seed scripts for development and testing environments. it uses faker libraries to create realistic data, maintains relational integrity, and allows configurable data volumes. u... Use when working with databases or data models. Trigger with phrases like 'database', 'query', or 'schema'.

1033

cursor-codebase-indexing

jeremylongshore

Execute set up and optimize Cursor codebase indexing. Triggers on "cursor index setup", "codebase indexing", "index codebase", "cursor semantic search". Use when working with cursor codebase indexing functionality. Trigger with phrases like "cursor codebase indexing", "cursor indexing", "cursor".

885

testing-mobile-apps

jeremylongshore

Execute mobile app testing on iOS and Android devices/simulators. Use when performing specialized testing. Trigger with phrases like "test mobile app", "run iOS tests", or "validate Android functionality".

810

You might also like

telegram-bot-builder

davila7

Expert in building Telegram bots that solve real problems - from simple automation to complex AI-powered bots. Covers bot architecture, the Telegram Bot API, user experience, monetization strategies, and scaling bots to thousands of users. Use when: telegram bot, bot api, telegram automation, chat bot telegram, tg bot.

106130

reddit-api

alinaqi

Reddit API with PRAW (Python) and Snoowrap (Node.js)

334

juicebox-install-auth

jeremylongshore

Install and configure Juicebox SDK/CLI authentication. Use when setting up a new Juicebox integration, configuring API keys, or initializing Juicebox in your project. Trigger with phrases like "install juicebox", "setup juicebox", "juicebox auth", "configure juicebox API key".

28

lindy-sdk-patterns

jeremylongshore

Lindy AI SDK best practices and common patterns. Use when learning SDK patterns, optimizing API usage, or implementing advanced agent features. Trigger with phrases like "lindy SDK patterns", "lindy best practices", "lindy API patterns", "lindy code patterns".

14

windsurf-mcp-integration

jeremylongshore

Manage integrate MCP servers with Windsurf for extended capabilities. Activate when users mention "mcp integration", "model context protocol", "external tools", "mcp server", or "cascade tools". Handles MCP server configuration and integration. Use when working with windsurf mcp integration functionality. Trigger with phrases like "windsurf mcp integration", "windsurf integration", "windsurf".

14

wox-plugin-creator

Wox-launcher

Create and scaffold Wox plugins (nodejs, python, script-nodejs, script-python). Use when cloning official SDK templates, generating script plugin templates, or preparing plugins for publish.

13

Search skills

Search the agent skills registry