| name | assemblyai-sdk-patterns |
| description | Apply production-ready AssemblyAI SDK patterns for TypeScript and Python.
Use when implementing AssemblyAI integrations, refactoring SDK usage,
or establishing team coding standards for transcription workflows.
Trigger with phrases like "assemblyai SDK patterns", "assemblyai best practices",
"assemblyai code patterns", "idiomatic assemblyai".
|
| allowed-tools | Read, Write, Edit |
| version | 1.5.0 |
| license | MIT |
| author | Jeremy Longshore <jeremy@intentsolutions.io> |
| tags | ["saas","ai","speech-to-text","assemblyai","transcription"] |
| compatibility | Designed for Claude Code |
AssemblyAI SDK Patterns
Overview
Production-ready patterns for the assemblyai npm package covering client initialization, type-safe wrappers, error handling, and multi-tenant architectures.
Prerequisites
assemblyai package installed (npm install assemblyai)
- Familiarity with async/await and TypeScript generics
Instructions
Step 1: Type-Safe Singleton Client
import { AssemblyAI } from 'assemblyai';
let instance: AssemblyAI | null = null;
export function getAssemblyAI(): AssemblyAI {
if (!instance) {
const apiKey = process.env.ASSEMBLYAI_API_KEY;
if (!apiKey) throw new Error('ASSEMBLYAI_API_KEY is required');
instance = new AssemblyAI({ apiKey });
}
return instance;
}
Step 2: Transcription Service Wrapper
import { AssemblyAI, type Transcript, type TranscriptParams } from 'assemblyai';
export interface TranscriptionResult {
: ;
: ;
: ;
: <{ : ; : ; : ; : }>;
?: <{ : ; : }>;
}
{
() {}
(
: ,
: <> = {}
): <> {
transcript = ...({
audio,
...options,
});
(transcript. === ) {
();
}
{
: transcript.,
: transcript. ?? ,
: transcript. ?? ,
: (transcript. ?? []).( ({
: w.,
: w.,
: w.,
: w.,
})),
: transcript.?.( ({
: u.,
: u.,
})),
};
}
(: ): <> {
...(id);
}
() {
page = ...(params);
page.;
}
(: ): <> {
...(id);
}
}