Table of Contents
Deepgram JavaScript SDK v5: A New Architecture, Better TypeScript
Install: npm install @deepgram/sdk@v5.0.0
The biggest change in v5? The SDK is now automatically generated directly from our API specs using Fern! Previously, types were maintained by hand... which sounds fine until you've spent 20 minutes chasing a type error on a field the API never actually makes optional. Generated types mean the TypeScript reflects what the API actually does, not what someone thought it did when they last updated the definitions.
New API features also land in the SDK through automated generation PRs, rather than waiting on a manual type update. Filler words, agent TTS provider fallback, mip_opt_out, ttl_seconds — they're all there. Flux model support is in too.
Before (v4):
import { Deepgram } from "@deepgram/sdk";
const deepgram = new Deepgram(process.env.DEEPGRAM_API_KEY!);
const { result, error } = await deepgram.transcription.preRecorded(
{ url: "https://example.com/audio.wav" },
{ model: "nova-2" }
);
// defensive chaining because types couldn't be trusted
const transcript =
result?.results?.channels?.[0]?.alternatives?.[0]?.transcript ?? "";After (v5):
import { DeepgramClient } from "@deepgram/sdk";
import type { ListenV1Response } from "@deepgram/sdk";
const client = new DeepgramClient();
const response: ListenV1Response = await client.listen.v1.media.transcribeUrl(
{ url: "https://example.com/audio.wav" },
{ model: "nova-3" }
);
const transcript = response.results.channels[0].alternatives[0].transcript;Migration guide (v4 → v5) · GitHub · npm
Deepgram Python SDK v6: Generated WebSockets and Custom Transports
Install: pip install deepgram-sdk@v6.0.1
v5 generated the REST clients from the spec... but v6 now does the same for WebSockets!
That's it, that's the post. The live transcription, TTS, and agent WebSocket connections were hand-rolled in v5. This led to inconsistencies that were annoying at best and confusing at worst. In v6 they're generated from the AsyncAPI spec, so they behave consistently and the types actually match what comes back over the wire.
A few other things that changed:
send_media()now takes raw bytes. Control messages have proper named methods —send_keep_alive(),send_finalize(),send_flush()— instead of the oldsend_control({"type": "..."})pattern that required you to look up the right structure every time.- Types are now imported from their feature namespace (
deepgram.listen.v1.types,deepgram.agent.v1.types) rather than a shared barrel. Autocomplete is actually useful now. - Custom transport support! You can swap out the built-in WebSocket transport with your own implementation, which is useful for testing, proxied environments, or non-standard protocols.
- SageMaker transport! There's a first-party
deepgram-sagemakerpackage for running Deepgram models on AWS SageMaker endpoints via HTTP/2 bidirectional streaming, under the same SDK interface.
Before (v5):
from deepgram import DeepgramClient
client = DeepgramClient()
connection = client.listen.live(
model="nova-2",
encoding="linear16",
sample_rate=16000
)
connection.on("open", lambda _: print("Connection opened"))
connection.on("message", lambda msg: print(msg))
connection.send_control({"type": "KeepAlive"})
connection.send_control({"type": "Finalize"})After (v6):
from deepgram import DeepgramClient
from deepgram.core.events import EventType
client = DeepgramClient()
with client.listen.v2.connect(
model="nova-3",
encoding="linear16",
sample_rate=16000
) as connection:
connection.on(EventType.OPEN, lambda _: print("Connection opened"))
connection.on(EventType.MESSAGE, lambda msg: print(msg.type))
connection.send_keep_alive()
connection.send_finalize()
connection.start_listening()Migration guide (v5 → v6) · GitHub · PyPI
Get Started with Deepgram’s SDKs
If you're new to Deepgram, grab a free API key and pick your SDK:
JavaScript / TypeScript:
npm install @deepgram/sdk@v5.0.0
Python:
pip install deepgram-sdk@v6.0.1
These are major releases and existing projects that are upgrading will likely break, so make sure to follow our in-depth migration guides. Run into something unexpected? Open an issue on GitHub or come find us in the Deepgram Discord.
What's Coming for Deepgram?
Already in the pipeline: SageMaker transport for the JavaScript SDK, on-the-fly configuration updates for both SDKs, Flux multilingual support, and new versions of the Rust and Go SDKs — plus a Java SDK that's currently in the works.
The Deepgram Discord is the best place to follow along as these land — that's where we share early updates, answer questions from developers actively building, and take feedback that ends up shaping what we prioritise next.
