Skip to content

v5.0.0-beta.1

Pre-release
Pre-release

Choose a tag to compare

@naomi-deepgram naomi-deepgram released this 16 Jan 02:21
1d5c800

We're thrilled to announce the first beta release of the Deepgram JavaScript SDK v5! This is a major rewrite that brings significant improvements to developer experience, type safety, and API consistency.

Highlights

  • Auto-generated SDK built with Fern for better maintainability and API consistency
  • Full TypeScript support with auto-generated types for all API responses
  • Versioned API namespaces (v1, v2) that mirror our REST API structure
  • Simplified error handling using standard try/catch instead of { result, error } destructuring
  • New V2 Live Transcription API with improved streaming capabilities
  • Native access token support for short-lived authentication

Breaking Changes

Client Initialization

// Before (v4)
import { createClient } from "@deepgram/sdk";
const deepgram = createClient("YOUR_API_KEY");

// After (v5)
import { DeepgramClient } from "@deepgram/sdk";
const deepgram = new DeepgramClient({ apiKey: "YOUR_API_KEY" });

API Method Paths

All API methods now include versioned namespaces:

v4 v5
listen.prerecorded.transcribeUrl() listen.v1.media.transcribeUrl()
listen.live() listen.v1.connect() / listen.v2.connect()
speak.request() speak.v1.audio.generate()
speak.live() speak.v1.connect()
read.analyzeText() read.v1.text.analyze()
manage.getProjects() manage.v1.projects.list()
auth.grantToken() auth.v1.tokens.grant()
onprem.* selfHosted.v1.distributionCredentials.*
models.getAll() manage.v1.models.list()

Error Handling

// Before (v4)
const { result, error } = await deepgram.listen.prerecorded.transcribeUrl(...);
if (error) { /* handle error */ }

// After (v5)
try {
  const data = await deepgram.listen.v1.media.transcribeUrl(...);
} catch (error) {
  // Error includes: statusCode, body, rawResponse
}

WebSocket Connections

// Before (v4)
const connection = deepgram.listen.live({ model: "nova-3" });
connection.on(LiveTranscriptionEvents.Transcript, (data) => { ... });

// After (v5)
const connection = await deepgram.listen.v1.connect({ model: "nova-3" });
connection.on("message", (data) => {
  if (data.type === "Results") { ... }
});
connection.connect();
await connection.waitForOpen();

New Features

V2 Live Transcription API

A new streaming transcription endpoint with improved features:

const connection = await deepgram.listen.v2.connect({ model: "flux-general-en" });
connection.on("message", (data) => {
  if (data.type === "TurnInfo") {
    console.log("Turn Info:", data);
  }
});
connection.connect();
await connection.waitForOpen();
connection.sendMedia(audioChunk);

Access Token Authentication

Native support for short-lived access tokens:

// Generate a token
const { accessToken } = await deepgram.auth.v1.tokens.grant();

// Use the token
const client = new DeepgramClient({ accessToken });

Session ID Tracking

Automatic session ID generation for request tracking and debugging.

Migration Guide

For detailed migration instructions, see our Migration Guide.

Installation

npm install @deepgram/sdk@beta

Feedback

This is a beta release and we'd love your feedback! Please open an issue on GitHub if you encounter any problems or have suggestions.