Back to Skills

deepgram-sdk-patterns

verified
View on GitHub

Marketplace

claude-code-plugins-plus

jeremylongshore/claude-code-plugins-plus-skills

Plugin

deepgram-pack

ai-ml

Repository

jeremylongshore/claude-code-plugins-plus-skills
1.1kstars

plugins/saas-packs/deepgram-pack/skills/deepgram-sdk-patterns/SKILL.md

Last Verified

January 22, 2026

Install Skill

Select agents to install to:

Scope:
npx add-skill https://github.com/jeremylongshore/claude-code-plugins-plus-skills/blob/main/plugins/saas-packs/deepgram-pack/skills/deepgram-sdk-patterns/SKILL.md -a claude-code --skill deepgram-sdk-patterns

Installation paths:

Claude
.claude/skills/deepgram-sdk-patterns/
Powered by add-skill CLI

Instructions

# Deepgram SDK Patterns

## Overview
Production-ready patterns for Deepgram SDK integration with proper error handling, typing, and structure.

## Prerequisites
- Completed `deepgram-install-auth` setup
- Familiarity with async/await patterns
- Understanding of error handling best practices

## Instructions

### Step 1: Create Type-Safe Client Singleton
Implement a singleton pattern for the Deepgram client.

### Step 2: Add Robust Error Handling
Wrap all API calls with proper error handling and logging.

### Step 3: Implement Response Validation
Validate API responses before processing.

### Step 4: Add Retry Logic
Implement exponential backoff for transient failures.

## Output
- Type-safe client singleton
- Robust error handling with structured logging
- Automatic retry with exponential backoff
- Runtime validation for API responses

## Error Handling
| Error | Cause | Solution |
|-------|-------|----------|
| Type Mismatch | Incorrect response shape | Add runtime validation |
| Client Undefined | Singleton not initialized | Call init() before use |
| Memory Leak | Multiple client instances | Use singleton pattern |
| Timeout | Large audio file | Increase timeout settings |

## Examples

### TypeScript Client Singleton
```typescript
// lib/deepgram.ts
import { createClient, DeepgramClient } from '@deepgram/sdk';

let client: DeepgramClient | null = null;

export function getDeepgramClient(): DeepgramClient {
  if (!client) {
    const apiKey = process.env.DEEPGRAM_API_KEY;
    if (!apiKey) {
      throw new Error('DEEPGRAM_API_KEY environment variable not set');
    }
    client = createClient(apiKey);
  }
  return client;
}

export function resetClient(): void {
  client = null;
}
```

### Typed Transcription Response
```typescript
// types/deepgram.ts
export interface TranscriptWord {
  word: string;
  start: number;
  end: number;
  confidence: number;
  punctuated_word?: string;
}

export interface TranscriptAlternative {
  transcript: string;
  confidence: nu

Validation Details

Front Matter
Required Fields
Valid Name Format
Valid Description
Has Sections
Allowed Tools
Instruction Length:
5464 chars