[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M78ZM2PNKQZ8HSQA482586SC":3,"skill-same:01M78ZM2PNKQZ8HSQA482586SC":59},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":16,"categories":17,"keywords":18,"publishedAt":19,"linkOnly":20,"markdownContent":21,"markdownBody":22,"frontMatter":23,"refName":36,"commitSha":37,"skillDirectory":38,"forksCount":39,"repositoryHtmlUrl":40,"repositoryHomepageUrl":6,"ownerHtmlUrl":41,"ownerBlogUrl":42,"ownerDescription":43,"updatedAt":44,"install":45,"resources":58},"01M78ZM2PNKQZ8HSQA482586SC","elevenlabs-reference-architecture",null,"Implement ElevenLabs reference architecture for production TTS\u002Fvoice applications.\nUse when designing new ElevenLabs integrations, reviewing project structure,\nor building a scalable audio generation service.\nTrigger: \"elevenlabs architecture\", \"elevenlabs project structure\",\n\"how to organize elevenlabs\", \"TTS service architecture\",\n\"elevenlabs design patterns\", \"voice API architecture\".","jukeyman\u002Fjukeyman-skills","jukeyman","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F142960420?v=4","01M78FR4Y3DHMMCBCC0GXXNB3F","RICK JEFFERSON","01M78FR4Z8RVQRAD31Y5J7V6EB",1,"MIT","https:\u002F\u002Fgithub.com\u002Fjukeyman\u002Fjukeyman-skills\u002Fblob\u002Fmain\u002Fskills\u002Fsaas-packs--elevenlabs-pack--elevenlabs-reference-architecture\u002FSKILL.md",[],[],"2026-11-15 14:19:17",false,"---\nname: elevenlabs-reference-architecture\ndescription: |\n  Implement ElevenLabs reference architecture for production TTS\u002Fvoice applications.\n  Use when designing new ElevenLabs integrations, reviewing project structure,\n  or building a scalable audio generation service.\n  Trigger: \"elevenlabs architecture\", \"elevenlabs project structure\",\n  \"how to organize elevenlabs\", \"TTS service architecture\",\n  \"elevenlabs design patterns\", \"voice API architecture\".\nallowed-tools: Read, Grep\nversion: 1.0.0\nlicense: MIT\nauthor: Jeremy Longshore \u003Cjeremy@intentsolutions.io>\ntags: [saas, voice, ai, elevenlabs, architecture, patterns]\ncompatible-with: claude-code\n---\n\n# ElevenLabs Reference Architecture\n\n## Overview\n\nProduction-ready architecture for ElevenLabs TTS\u002Fvoice applications. Covers project layout, service layers, caching, streaming, and multi-model orchestration.\n\n## Prerequisites\n\n- Understanding of layered architecture patterns\n- ElevenLabs SDK knowledge (see `elevenlabs-sdk-patterns`)\n- TypeScript project with async patterns\n- Redis (optional, for distributed caching)\n\n## Instructions\n\n### Step 1: Project Structure\n\n```\nmy-elevenlabs-service\u002F\n├── src\u002F\n│   ├── elevenlabs\u002F\n│   │   ├── client.ts            # Singleton client with retry config\n│   │   ├── config.ts            # Environment-aware configuration\n│   │   ├── models.ts            # Model selection logic\n│   │   ├── errors.ts            # Error classification (see sdk-patterns)\n│   │   └── types.ts             # TypeScript interfaces\n│   ├── services\u002F\n│   │   ├── tts-service.ts       # Text-to-Speech orchestration\n│   │   ├── voice-service.ts     # Voice management (clone, list, settings)\n│   │   ├── audio-service.ts     # SFX, isolation, transcription\n│   │   └── cache-service.ts     # Audio caching layer\n│   ├── api\u002F\n│   │   ├── routes\u002F\n│   │   │   ├── tts.ts           # POST \u002Fapi\u002Ftts\n│   │   │   ├── voices.ts        # GET\u002FPOST \u002Fapi\u002Fvoices\n│   │   │   ├── webhooks.ts      # POST \u002Fwebhooks\u002Felevenlabs\n│   │   │   └── health.ts        # GET \u002Fhealth\n│   │   └── middleware\u002F\n│   │       ├── rate-limit.ts    # Request throttling\n│   │       └── auth.ts          # Your app's auth (not ElevenLabs auth)\n│   ├── queue\u002F\n│   │   ├── tts-queue.ts         # Async TTS job processing\n│   │   └── workers.ts           # Queue workers\n│   └── monitoring\u002F\n│       ├── metrics.ts           # Latency, error rate, quota tracking\n│       └── alerts.ts            # Budget and health alerts\n├── tests\u002F\n│   ├── unit\u002F\n│   │   ├── tts-service.test.ts\n│   │   └── cache-service.test.ts\n│   └── integration\u002F\n│       └── tts-smoke.test.ts\n├── config\u002F\n│   ├── development.json\n│   ├── staging.json\n│   └── production.json\n└── .env.example\n```\n\n### Step 2: Configuration Layer\n\n```typescript\n\u002F\u002F src\u002Felevenlabs\u002Fconfig.ts\nexport interface ElevenLabsConfig {\n  apiKey: string;\n  environment: \"development\" | \"staging\" | \"production\";\n  defaults: {\n    modelId: string;\n    voiceId: string;\n    outputFormat: string;\n    voiceSettings: {\n      stability: number;\n      similarity_boost: number;\n      style: number;\n      speed: number;\n    };\n  };\n  performance: {\n    maxConcurrency: number;\n    timeoutMs: number;\n    maxRetries: number;\n  };\n  cache: {\n    enabled: boolean;\n    maxSizeMB: number;\n    ttlSeconds: number;\n  };\n}\n\nconst ENV_CONFIGS: Record\u003Cstring, Partial\u003CElevenLabsConfig>> = {\n  development: {\n    defaults: {\n      modelId: \"eleven_flash_v2_5\",    \u002F\u002F Cheap + fast for dev\n      voiceId: \"21m00Tcm4TlvDq8ikWAM\", \u002F\u002F Rachel\n      outputFormat: \"mp3_22050_32\",     \u002F\u002F Small files\n      voiceSettings: { stability: 0.5, similarity_boost: 0.75, style: 0, speed: 1 },\n    },\n    performance: { maxConcurrency: 2, timeoutMs: 30_000, maxRetries: 1 },\n    cache: { enabled: true, maxSizeMB: 50, ttlSeconds: 3600 },\n  },\n  production: {\n    defaults: {\n      modelId: \"eleven_multilingual_v2\", \u002F\u002F High quality for prod\n      voiceId: \"21m00Tcm4TlvDq8ikWAM\",\n      outputFormat: \"mp3_44100_128\",     \u002F\u002F High quality\n      voiceSettings: { stability: 0.5, similarity_boost: 0.75, style: 0, speed: 1 },\n    },\n    performance: { maxConcurrency: 10, timeoutMs: 60_000, maxRetries: 3 },\n    cache: { enabled: true, maxSizeMB: 500, ttlSeconds: 86_400 },\n  },\n};\n\nexport function loadConfig(): ElevenLabsConfig {\n  const env = process.env.NODE_ENV || \"development\";\n  const envConfig = ENV_CONFIGS[env] || ENV_CONFIGS.development;\n\n  return {\n    apiKey: process.env.ELEVENLABS_API_KEY!,\n    environment: env as any,\n    ...envConfig,\n  } as ElevenLabsConfig;\n}\n```\n\n### Step 3: TTS Service Layer\n\n```typescript\n\u002F\u002F src\u002Fservices\u002Ftts-service.ts\nimport { ElevenLabsClient } from \"@elevenlabs\u002Felevenlabs-js\";\nimport PQueue from \"p-queue\";\nimport { loadConfig } from \"..\u002Felevenlabs\u002Fconfig\";\nimport { classifyError } from \"..\u002Felevenlabs\u002Ferrors\";\n\nexport class TTSService {\n  private client: ElevenLabsClient;\n  private queue: PQueue;\n  private config: ReturnType\u003Ctypeof loadConfig>;\n\n  constructor() {\n    this.config = loadConfig();\n    this.client = new ElevenLabsClient({\n      apiKey: this.config.apiKey,\n      maxRetries: this.config.performance.maxRetries,\n      timeoutInSeconds: this.config.performance.timeoutMs \u002F 1000,\n    });\n    this.queue = new PQueue({\n      concurrency: this.config.performance.maxConcurrency,\n    });\n  }\n\n  async generate(text: string, options?: {\n    voiceId?: string;\n    modelId?: string;\n    outputFormat?: string;\n    streaming?: boolean;\n  }): Promise\u003CReadableStream | Buffer> {\n    const voiceId = options?.voiceId || this.config.defaults.voiceId;\n    const modelId = options?.modelId || this.config.defaults.modelId;\n    const format = options?.outputFormat || this.config.defaults.outputFormat;\n\n    return this.queue.add(async () => {\n      const start = performance.now();\n\n      try {\n        if (options?.streaming) {\n          return await this.client.textToSpeech.stream(voiceId, {\n            text,\n            model_id: modelId,\n            output_format: format,\n            voice_settings: this.config.defaults.voiceSettings,\n          });\n        }\n\n        const audio = await this.client.textToSpeech.convert(voiceId, {\n          text,\n          model_id: modelId,\n          output_format: format,\n          voice_settings: this.config.defaults.voiceSettings,\n        });\n\n        const latency = performance.now() - start;\n        console.log(`[TTS] ${text.length} chars, ${modelId}, ${latency.toFixed(0)}ms`);\n        return audio;\n      } catch (error) {\n        throw classifyError(error);\n      }\n    }) as Promise\u003CReadableStream | Buffer>;\n  }\n\n  \u002F\u002F Split long text into chunks with prosody context\n  async generateLongText(text: string, voiceId?: string): Promise\u003CBuffer[]> {\n    const chunks = this.splitText(text, 4500); \u002F\u002F Stay under 5000 limit\n    const results: Buffer[] = [];\n\n    for (let i = 0; i \u003C chunks.length; i++) {\n      const audio = await this.generate(chunks[i], {\n        voiceId,\n        \u002F\u002F Pass context for natural prosody across chunks\n      });\n      results.push(audio as Buffer);\n    }\n\n    return results;\n  }\n\n  private splitText(text: string, maxChars: number): string[] {\n    const chunks: string[] = [];\n    const sentences = text.match(\u002F[^.!?]+[.!?]+\u002Fg) || [text];\n    let current = \"\";\n\n    for (const sentence of sentences) {\n      if ((current + sentence).length > maxChars) {\n        if (current) chunks.push(current.trim());\n        current = sentence;\n      } else {\n        current += sentence;\n      }\n    }\n    if (current) chunks.push(current.trim());\n    return chunks;\n  }\n}\n```\n\n### Step 4: Voice Management Service\n\n```typescript\n\u002F\u002F src\u002Fservices\u002Fvoice-service.ts\nexport class VoiceService {\n  private client: ElevenLabsClient;\n\n  constructor(client: ElevenLabsClient) {\n    this.client = client;\n  }\n\n  async listVoices(filter?: { category?: \"premade\" | \"cloned\" | \"generated\" }) {\n    const { voices } = await this.client.voices.getAll();\n    if (filter?.category) {\n      return voices.filter(v => v.category === filter.category);\n    }\n    return voices;\n  }\n\n  async cloneVoice(name: string, description: string, audioFiles: NodeJS.ReadableStream[]) {\n    return this.client.voices.add({\n      name,\n      description,\n      files: audioFiles,\n    });\n  }\n\n  async getVoiceSettings(voiceId: string) {\n    return this.client.voices.getSettings(voiceId);\n  }\n\n  async updateVoiceSettings(voiceId: string, settings: {\n    stability: number;\n    similarity_boost: number;\n  }) {\n    return this.client.voices.editSettings(voiceId, settings);\n  }\n\n  async deleteVoice(voiceId: string) {\n    return this.client.voices.delete(voiceId);\n  }\n}\n```\n\n### Step 5: Data Flow Diagram\n\n```\n                         ┌──────────────┐\n                         │   Client     │\n                         │  (Browser\u002F   │\n                         │   Mobile)    │\n                         └──────┬───────┘\n                                │\n                         ┌──────▼───────┐\n                         │   API Layer  │\n                         │   \u002Fapi\u002Ftts   │\n                         │   \u002Fapi\u002Fvoice │\n                         └──────┬───────┘\n                                │\n                    ┌───────────┼───────────┐\n                    │           │           │\n             ┌──────▼──┐ ┌─────▼─────┐ ┌──▼──────┐\n             │  Cache   │ │   TTS     │ │  Voice  │\n             │ Service  │ │  Service  │ │ Service │\n             └──────┬───┘ └─────┬─────┘ └────────┘\n                    │           │\n              ┌─────▼─┐  ┌─────▼──────────┐\n              │ Redis\u002F │  │ Concurrency    │\n              │ LRU    │  │ Queue (p-queue)│\n              └────────┘  └─────┬──────────┘\n                                │\n                         ┌──────▼───────┐\n                         │  ElevenLabs  │\n                         │  Client SDK  │\n                         │  (singleton) │\n                         └──────┬───────┘\n                                │\n                    ┌───────────┼───────────┐\n                    │           │           │\n             ┌──────▼──┐ ┌─────▼─────┐ ┌──▼──────┐\n             │ \u002Fv1\u002Ftts  │ │ \u002Fv1\u002Fvoices│ │ \u002Fv1\u002Fsfx │\n             │ REST\u002FWS  │ │  REST     │ │  REST   │\n             └──────────┘ └───────────┘ └─────────┘\n                    ElevenLabs API (api.elevenlabs.io)\n```\n\n### Step 6: Health Check Composition\n\n```typescript\n\u002F\u002F src\u002Fapi\u002Froutes\u002Fhealth.ts\nexport async function healthCheck() {\n  const checks = await Promise.allSettled([\n    checkElevenLabsConnectivity(),\n    checkQuotaStatus(),\n    checkCacheHealth(),\n  ]);\n\n  const elevenlabs = checks[0].status === \"fulfilled\" ? checks[0].value : null;\n  const quota = checks[1].status === \"fulfilled\" ? checks[1].value : null;\n  const cache = checks[2].status === \"fulfilled\" ? checks[2].value : null;\n\n  const degraded = !elevenlabs || (quota && quota.pctUsed > 90);\n\n  return {\n    status: !elevenlabs ? \"unhealthy\" : degraded ? \"degraded\" : \"healthy\",\n    services: { elevenlabs, quota, cache },\n    timestamp: new Date().toISOString(),\n  };\n}\n```\n\n## Architecture Decisions\n\n| Decision | Choice | Rationale |\n|----------|--------|-----------|\n| Client pattern | Singleton | One connection pool, shared retry config |\n| Concurrency | p-queue | Respects plan limits, prevents 429 |\n| Caching | LRU (local) or Redis (distributed) | Repeated content is common in TTS |\n| Long text | Sentence-boundary splitting | Preserves natural speech prosody |\n| Error handling | Classification + retry | Different strategies for 429 vs 401 vs 500 |\n| Model selection | Environment-based | Flash in dev (cheap), Multilingual in prod (quality) |\n| Streaming | HTTP streaming + WebSocket | HTTP for simple, WS for LLM integration |\n\n## Error Handling\n\n| Issue | Cause | Solution |\n|-------|-------|----------|\n| Circular dependencies | Wrong layering | Services depend on client, never reverse |\n| Cold start latency | Client initialization | Pre-warm in server startup |\n| Memory pressure | Unbounded audio cache | Set `maxSizeMB` on cache |\n| Type errors | SDK version mismatch | Pin SDK version in package.json |\n\n## Resources\n\n- [ElevenLabs API Reference](https:\u002F\u002Felevenlabs.io\u002Fdocs\u002Fapi-reference\u002Fintroduction)\n- [ElevenLabs SDK Source](https:\u002F\u002Fgithub.com\u002Felevenlabs\u002Felevenlabs-js)\n- [p-queue](https:\u002F\u002Fgithub.com\u002Fsindresorhus\u002Fp-queue)\n- [LRU Cache](https:\u002F\u002Fgithub.com\u002Fisaacs\u002Fnode-lru-cache)\n\n## Next Steps\n\nStart with `elevenlabs-install-auth` for setup, then apply this architecture. Use `elevenlabs-core-workflow-a` and `elevenlabs-core-workflow-b` for feature implementation.\n","# ElevenLabs Reference Architecture\n\n## Overview\n\nProduction-ready architecture for ElevenLabs TTS\u002Fvoice applications. Covers project layout, service layers, caching, streaming, and multi-model orchestration.\n\n## Prerequisites\n\n- Understanding of layered architecture patterns\n- ElevenLabs SDK knowledge (see `elevenlabs-sdk-patterns`)\n- TypeScript project with async patterns\n- Redis (optional, for distributed caching)\n\n## Instructions\n\n### Step 1: Project Structure\n\n```\nmy-elevenlabs-service\u002F\n├── src\u002F\n│   ├── elevenlabs\u002F\n│   │   ├── client.ts            # Singleton client with retry config\n│   │   ├── config.ts            # Environment-aware configuration\n│   │   ├── models.ts            # Model selection logic\n│   │   ├── errors.ts            # Error classification (see sdk-patterns)\n│   │   └── types.ts             # TypeScript interfaces\n│   ├── services\u002F\n│   │   ├── tts-service.ts       # Text-to-Speech orchestration\n│   │   ├── voice-service.ts     # Voice management (clone, list, settings)\n│   │   ├── audio-service.ts     # SFX, isolation, transcription\n│   │   └── cache-service.ts     # Audio caching layer\n│   ├── api\u002F\n│   │   ├── routes\u002F\n│   │   │   ├── tts.ts           # POST \u002Fapi\u002Ftts\n│   │   │   ├── voices.ts        # GET\u002FPOST \u002Fapi\u002Fvoices\n│   │   │   ├── webhooks.ts      # POST \u002Fwebhooks\u002Felevenlabs\n│   │   │   └── health.ts        # GET \u002Fhealth\n│   │   └── middleware\u002F\n│   │       ├── rate-limit.ts    # Request throttling\n│   │       └── auth.ts          # Your app's auth (not ElevenLabs auth)\n│   ├── queue\u002F\n│   │   ├── tts-queue.ts         # Async TTS job processing\n│   │   └── workers.ts           # Queue workers\n│   └── monitoring\u002F\n│       ├── metrics.ts           # Latency, error rate, quota tracking\n│       └── alerts.ts            # Budget and health alerts\n├── tests\u002F\n│   ├── unit\u002F\n│   │   ├── tts-service.test.ts\n│   │   └── cache-service.test.ts\n│   └── integration\u002F\n│       └── tts-smoke.test.ts\n├── config\u002F\n│   ├── development.json\n│   ├── staging.json\n│   └── production.json\n└── .env.example\n```\n\n### Step 2: Configuration Layer\n\n```typescript\n\u002F\u002F src\u002Felevenlabs\u002Fconfig.ts\nexport interface ElevenLabsConfig {\n  apiKey: string;\n  environment: \"development\" | \"staging\" | \"production\";\n  defaults: {\n    modelId: string;\n    voiceId: string;\n    outputFormat: string;\n    voiceSettings: {\n      stability: number;\n      similarity_boost: number;\n      style: number;\n      speed: number;\n    };\n  };\n  performance: {\n    maxConcurrency: number;\n    timeoutMs: number;\n    maxRetries: number;\n  };\n  cache: {\n    enabled: boolean;\n    maxSizeMB: number;\n    ttlSeconds: number;\n  };\n}\n\nconst ENV_CONFIGS: Record\u003Cstring, Partial\u003CElevenLabsConfig>> = {\n  development: {\n    defaults: {\n      modelId: \"eleven_flash_v2_5\",    \u002F\u002F Cheap + fast for dev\n      voiceId: \"21m00Tcm4TlvDq8ikWAM\", \u002F\u002F Rachel\n      outputFormat: \"mp3_22050_32\",     \u002F\u002F Small files\n      voiceSettings: { stability: 0.5, similarity_boost: 0.75, style: 0, speed: 1 },\n    },\n    performance: { maxConcurrency: 2, timeoutMs: 30_000, maxRetries: 1 },\n    cache: { enabled: true, maxSizeMB: 50, ttlSeconds: 3600 },\n  },\n  production: {\n    defaults: {\n      modelId: \"eleven_multilingual_v2\", \u002F\u002F High quality for prod\n      voiceId: \"21m00Tcm4TlvDq8ikWAM\",\n      outputFormat: \"mp3_44100_128\",     \u002F\u002F High quality\n      voiceSettings: { stability: 0.5, similarity_boost: 0.75, style: 0, speed: 1 },\n    },\n    performance: { maxConcurrency: 10, timeoutMs: 60_000, maxRetries: 3 },\n    cache: { enabled: true, maxSizeMB: 500, ttlSeconds: 86_400 },\n  },\n};\n\nexport function loadConfig(): ElevenLabsConfig {\n  const env = process.env.NODE_ENV || \"development\";\n  const envConfig = ENV_CONFIGS[env] || ENV_CONFIGS.development;\n\n  return {\n    apiKey: process.env.ELEVENLABS_API_KEY!,\n    environment: env as any,\n    ...envConfig,\n  } as ElevenLabsConfig;\n}\n```\n\n### Step 3: TTS Service Layer\n\n```typescript\n\u002F\u002F src\u002Fservices\u002Ftts-service.ts\nimport { ElevenLabsClient } from \"@elevenlabs\u002Felevenlabs-js\";\nimport PQueue from \"p-queue\";\nimport { loadConfig } from \"..\u002Felevenlabs\u002Fconfig\";\nimport { classifyError } from \"..\u002Felevenlabs\u002Ferrors\";\n\nexport class TTSService {\n  private client: ElevenLabsClient;\n  private queue: PQueue;\n  private config: ReturnType\u003Ctypeof loadConfig>;\n\n  constructor() {\n    this.config = loadConfig();\n    this.client = new ElevenLabsClient({\n      apiKey: this.config.apiKey,\n      maxRetries: this.config.performance.maxRetries,\n      timeoutInSeconds: this.config.performance.timeoutMs \u002F 1000,\n    });\n    this.queue = new PQueue({\n      concurrency: this.config.performance.maxConcurrency,\n    });\n  }\n\n  async generate(text: string, options?: {\n    voiceId?: string;\n    modelId?: string;\n    outputFormat?: string;\n    streaming?: boolean;\n  }): Promise\u003CReadableStream | Buffer> {\n    const voiceId = options?.voiceId || this.config.defaults.voiceId;\n    const modelId = options?.modelId || this.config.defaults.modelId;\n    const format = options?.outputFormat || this.config.defaults.outputFormat;\n\n    return this.queue.add(async () => {\n      const start = performance.now();\n\n      try {\n        if (options?.streaming) {\n          return await this.client.textToSpeech.stream(voiceId, {\n            text,\n            model_id: modelId,\n            output_format: format,\n            voice_settings: this.config.defaults.voiceSettings,\n          });\n        }\n\n        const audio = await this.client.textToSpeech.convert(voiceId, {\n          text,\n          model_id: modelId,\n          output_format: format,\n          voice_settings: this.config.defaults.voiceSettings,\n        });\n\n        const latency = performance.now() - start;\n        console.log(`[TTS] ${text.length} chars, ${modelId}, ${latency.toFixed(0)}ms`);\n        return audio;\n      } catch (error) {\n        throw classifyError(error);\n      }\n    }) as Promise\u003CReadableStream | Buffer>;\n  }\n\n  \u002F\u002F Split long text into chunks with prosody context\n  async generateLongText(text: string, voiceId?: string): Promise\u003CBuffer[]> {\n    const chunks = this.splitText(text, 4500); \u002F\u002F Stay under 5000 limit\n    const results: Buffer[] = [];\n\n    for (let i = 0; i \u003C chunks.length; i++) {\n      const audio = await this.generate(chunks[i], {\n        voiceId,\n        \u002F\u002F Pass context for natural prosody across chunks\n      });\n      results.push(audio as Buffer);\n    }\n\n    return results;\n  }\n\n  private splitText(text: string, maxChars: number): string[] {\n    const chunks: string[] = [];\n    const sentences = text.match(\u002F[^.!?]+[.!?]+\u002Fg) || [text];\n    let current = \"\";\n\n    for (const sentence of sentences) {\n      if ((current + sentence).length > maxChars) {\n        if (current) chunks.push(current.trim());\n        current = sentence;\n      } else {\n        current += sentence;\n      }\n    }\n    if (current) chunks.push(current.trim());\n    return chunks;\n  }\n}\n```\n\n### Step 4: Voice Management Service\n\n```typescript\n\u002F\u002F src\u002Fservices\u002Fvoice-service.ts\nexport class VoiceService {\n  private client: ElevenLabsClient;\n\n  constructor(client: ElevenLabsClient) {\n    this.client = client;\n  }\n\n  async listVoices(filter?: { category?: \"premade\" | \"cloned\" | \"generated\" }) {\n    const { voices } = await this.client.voices.getAll();\n    if (filter?.category) {\n      return voices.filter(v => v.category === filter.category);\n    }\n    return voices;\n  }\n\n  async cloneVoice(name: string, description: string, audioFiles: NodeJS.ReadableStream[]) {\n    return this.client.voices.add({\n      name,\n      description,\n      files: audioFiles,\n    });\n  }\n\n  async getVoiceSettings(voiceId: string) {\n    return this.client.voices.getSettings(voiceId);\n  }\n\n  async updateVoiceSettings(voiceId: string, settings: {\n    stability: number;\n    similarity_boost: number;\n  }) {\n    return this.client.voices.editSettings(voiceId, settings);\n  }\n\n  async deleteVoice(voiceId: string) {\n    return this.client.voices.delete(voiceId);\n  }\n}\n```\n\n### Step 5: Data Flow Diagram\n\n```\n                         ┌──────────────┐\n                         │   Client     │\n                         │  (Browser\u002F   │\n                         │   Mobile)    │\n                         └──────┬───────┘\n                                │\n                         ┌──────▼───────┐\n                         │   API Layer  │\n                         │   \u002Fapi\u002Ftts   │\n                         │   \u002Fapi\u002Fvoice │\n                         └──────┬───────┘\n                                │\n                    ┌───────────┼───────────┐\n                    │           │           │\n             ┌──────▼──┐ ┌─────▼─────┐ ┌──▼──────┐\n             │  Cache   │ │   TTS     │ │  Voice  │\n             │ Service  │ │  Service  │ │ Service │\n             └──────┬───┘ └─────┬─────┘ └────────┘\n                    │           │\n              ┌─────▼─┐  ┌─────▼──────────┐\n              │ Redis\u002F │  │ Concurrency    │\n              │ LRU    │  │ Queue (p-queue)│\n              └────────┘  └─────┬──────────┘\n                                │\n                         ┌──────▼───────┐\n                         │  ElevenLabs  │\n                         │  Client SDK  │\n                         │  (singleton) │\n                         └──────┬───────┘\n                                │\n                    ┌───────────┼───────────┐\n                    │           │           │\n             ┌──────▼──┐ ┌─────▼─────┐ ┌──▼──────┐\n             │ \u002Fv1\u002Ftts  │ │ \u002Fv1\u002Fvoices│ │ \u002Fv1\u002Fsfx │\n             │ REST\u002FWS  │ │  REST     │ │  REST   │\n             └──────────┘ └───────────┘ └─────────┘\n                    ElevenLabs API (api.elevenlabs.io)\n```\n\n### Step 6: Health Check Composition\n\n```typescript\n\u002F\u002F src\u002Fapi\u002Froutes\u002Fhealth.ts\nexport async function healthCheck() {\n  const checks = await Promise.allSettled([\n    checkElevenLabsConnectivity(),\n    checkQuotaStatus(),\n    checkCacheHealth(),\n  ]);\n\n  const elevenlabs = checks[0].status === \"fulfilled\" ? checks[0].value : null;\n  const quota = checks[1].status === \"fulfilled\" ? checks[1].value : null;\n  const cache = checks[2].status === \"fulfilled\" ? checks[2].value : null;\n\n  const degraded = !elevenlabs || (quota && quota.pctUsed > 90);\n\n  return {\n    status: !elevenlabs ? \"unhealthy\" : degraded ? \"degraded\" : \"healthy\",\n    services: { elevenlabs, quota, cache },\n    timestamp: new Date().toISOString(),\n  };\n}\n```\n\n## Architecture Decisions\n\n| Decision | Choice | Rationale |\n|----------|--------|-----------|\n| Client pattern | Singleton | One connection pool, shared retry config |\n| Concurrency | p-queue | Respects plan limits, prevents 429 |\n| Caching | LRU (local) or Redis (distributed) | Repeated content is common in TTS |\n| Long text | Sentence-boundary splitting | Preserves natural speech prosody |\n| Error handling | Classification + retry | Different strategies for 429 vs 401 vs 500 |\n| Model selection | Environment-based | Flash in dev (cheap), Multilingual in prod (quality) |\n| Streaming | HTTP streaming + WebSocket | HTTP for simple, WS for LLM integration |\n\n## Error Handling\n\n| Issue | Cause | Solution |\n|-------|-------|----------|\n| Circular dependencies | Wrong layering | Services depend on client, never reverse |\n| Cold start latency | Client initialization | Pre-warm in server startup |\n| Memory pressure | Unbounded audio cache | Set `maxSizeMB` on cache |\n| Type errors | SDK version mismatch | Pin SDK version in package.json |\n\n## Resources\n\n- [ElevenLabs API Reference](https:\u002F\u002Felevenlabs.io\u002Fdocs\u002Fapi-reference\u002Fintroduction)\n- [ElevenLabs SDK Source](https:\u002F\u002Fgithub.com\u002Felevenlabs\u002Felevenlabs-js)\n- [p-queue](https:\u002F\u002Fgithub.com\u002Fsindresorhus\u002Fp-queue)\n- [LRU Cache](https:\u002F\u002Fgithub.com\u002Fisaacs\u002Fnode-lru-cache)\n\n## Next Steps\n\nStart with `elevenlabs-install-auth` for setup, then apply this architecture. Use `elevenlabs-core-workflow-a` and `elevenlabs-core-workflow-b` for feature implementation.\n",{"name":5,"tags":24,"author":31,"license":15,"version":32,"description":33,"allowed-tools":34,"compatible-with":35},[25,26,27,28,29,30],"saas","voice","ai","elevenlabs","architecture","patterns","Jeremy Longshore \u003Cjeremy@intentsolutions.io>","1.0.0","Implement ElevenLabs reference architecture for production TTS\u002Fvoice applications.\nUse when designing new ElevenLabs integrations, reviewing project structure,\nor building a scalable audio generation service.\nTrigger: \"elevenlabs architecture\", \"elevenlabs project structure\",\n\"how to organize elevenlabs\", \"TTS service architecture\",\n\"elevenlabs design patterns\", \"voice API architecture\".\n","Read, Grep","claude-code","main","99825ad3f3bcc6597ddcc7294a14e6e922f2b67b","skills\u002Fsaas-packs--elevenlabs-pack--elevenlabs-reference-architecture",0,"https:\u002F\u002Fgithub.com\u002Fjukeyman\u002Fjukeyman-skills","https:\u002F\u002Fgithub.com\u002Fjukeyman","https:\u002F\u002FRJBUSINESSSOLUTIONS.ORG","Credit and Finance Expert | Developer\r\n\r\nI'm Rick Jefferson, a seasoned credit and finance expert with over a decade of experience in financial literacy,","2026-07-13 07:03:29",{"source":8,"skillName":5,"commands":46,"prompt":56,"zipAvailable":57},[47,50,53],{"tool":48,"command":49},"npx","npx skills add jukeyman\u002Fjukeyman-skills --skill elevenlabs-reference-architecture",{"tool":51,"command":52},"bunx","bunx skills add jukeyman\u002Fjukeyman-skills --skill elevenlabs-reference-architecture",{"tool":54,"command":55},"pnpm","pnpm dlx skills add jukeyman\u002Fjukeyman-skills --skill elevenlabs-reference-architecture","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Fjukeyman\u002Fjukeyman-skills\u002Fblob\u002Fmain\u002Fskills\u002Fsaas-packs--elevenlabs-pack--elevenlabs-reference-architecture\u002FSKILL.md",true,[],[60,67,74,81,88,96],{"skillNo":61,"name":62,"nameZh":6,"description":63,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":64,"categories":65,"keywords":66,"publishedAt":19},"01M79ANS2SM329NEP5ZCX106RR","zustand-store-creator","Create zustand store creator operations. Auto-activating skill for Frontend Development.\nTriggers on: zustand store creator, zustand store creator\nPart of the Frontend Development skill category. Use when working with zustand store creator functionality. Trigger with phrases like \"zustand store creator\", \"zustand creator\", \"zustand\".","https:\u002F\u002Fgithub.com\u002Fjukeyman\u002Fjukeyman-skills\u002Fblob\u002Fmain\u002Fskills\u002Fzustand-store-creator\u002FSKILL.md",[],[],{"skillNo":68,"name":69,"nameZh":6,"description":70,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":71,"categories":72,"keywords":73,"publishedAt":19},"01M79AMZKP4YDEZ7EHG1Y7PP74","zero-trust-config-helper","Configure with zero trust config helper operations. Auto-activating skill for Security Advanced.\nTriggers on: zero trust config helper, zero trust config helper\nPart of the Security Advanced skill category. Use when configuring systems or services. Trigger with phrases like \"zero trust config helper\", \"zero helper\", \"zero\".","https:\u002F\u002Fgithub.com\u002Fjukeyman\u002Fjukeyman-skills\u002Fblob\u002Fmain\u002Fskills\u002Fzero-trust-config-helper\u002FSKILL.md",[],[],{"skillNo":75,"name":76,"nameZh":6,"description":77,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":78,"categories":79,"keywords":80,"publishedAt":19},"01M79AMJSBCEJQNBTYNAHYN5HM","zapier-integration-helper","Assist with zapier integration helper operations. Auto-activating skill for Business Automation.\nTriggers on: zapier integration helper, zapier integration helper\nPart of the Business Automation skill category. Use when working with APIs or building integrations. Trigger with phrases like \"zapier integration helper\", \"zapier helper\", \"zapier\".","https:\u002F\u002Fgithub.com\u002Fjukeyman\u002Fjukeyman-skills\u002Fblob\u002Fmain\u002Fskills\u002Fzapier-integration-helper\u002FSKILL.md",[],[],{"skillNo":82,"name":83,"nameZh":6,"description":84,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":85,"categories":86,"keywords":87,"publishedAt":19},"01M79AHJZGVMARS13VFQYRR1MP","yaml-config-validator","Validate yaml config validator operations. Auto-activating skill for DevOps Basics.\nTriggers on: yaml config validator, yaml config validator\nPart of the DevOps Basics skill category. Use when configuring systems or services. Trigger with phrases like \"yaml config validator\", \"yaml validator\", \"yaml\".","https:\u002F\u002Fgithub.com\u002Fjukeyman\u002Fjukeyman-skills\u002Fblob\u002Fmain\u002Fskills\u002Fyaml-config-validator\u002FSKILL.md",[],[],{"skillNo":89,"name":90,"nameZh":6,"description":91,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":92,"sourceHtmlUrl":93,"categories":94,"keywords":95,"publishedAt":19},"01M79AHGDZRN0020RDQSQDPAM8","xvary-stock-research","Thesis-driven equity analysis from public SEC EDGAR and market data; \u002Fanalyze, \u002Fscore, \u002Fcompare workflows with bundled Python tools (Claude Code, Cursor, Codex).","https:\u002F\u002Fgithub.com\u002Fjukeyman\u002Fjukeyman-skills\u002Fblob\u002Fmain\u002Fskills\u002Fxvary-stock-research\u002FLICENSE","https:\u002F\u002Fgithub.com\u002Fjukeyman\u002Fjukeyman-skills\u002Fblob\u002Fmain\u002Fskills\u002Fxvary-stock-research\u002FSKILL.md",[],[],{"skillNo":97,"name":98,"nameZh":6,"description":99,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":100,"categories":101,"keywords":102,"publishedAt":19},"01M79AHCYJ9FV9RMHQ24HDRN33","xss-vulnerability-scanner","Scan xss vulnerability scanner operations. Auto-activating skill for Security Fundamentals.\nTriggers on: xss vulnerability scanner, xss vulnerability scanner\nPart of the Security Fundamentals skill category. Use when working with xss vulnerability scanner functionality. Trigger with phrases like \"xss vulnerability scanner\", \"xss scanner\", \"xss\".","https:\u002F\u002Fgithub.com\u002Fjukeyman\u002Fjukeyman-skills\u002Fblob\u002Fmain\u002Fskills\u002Fxss-vulnerability-scanner\u002FSKILL.md",[],[]]