Deepgram Python SDK
Official Python client for Deepgram's speech AI APIs
About
The official Python SDK for Deepgram's speech and language AI APIs. It provides typed sync (DeepgramClient) and async (AsyncDeepgramClient) clients for realtime speech recognition (Listen v2 / Flux with contextual turn detection, plus v1 Nova models for streaming and batch), prerecorded file transcription, text-to-speech (Speak v1 Aura voices, v2 Flux streaming TTS with pause/pronunciation/speed controls), the Voice Agent API (fully managed STT+LLM+TTS agent with function calling over WebSocket), and language understanding features (sentiment, topics, intents, redaction, diarization). Built with Fern, fully typed, with extensive examples.
What it can do
- Listen v2 (Flux): realtime streaming STT with contextual turn detection, numerals formatting, redaction, typed warnings
- Listen v1: streaming + batch transcription with Nova models (e.g. nova-3), diarization, language detection, keywords, sentiment/topics/intents
- Speak v1/v2: TTS with Aura voices and Flux streaming TTS — inline pause markers, IPA pronunciation overrides, speed/expressivity controls, barge-in interruption
- Voice Agent API: managed agent WebSocket with function calling (incl. `defer_until_eot` and `FunctionCallCancelled` events)
- Both sync and async clients, configurable retries (`max_retries`), custom transports for proxies/test doubles; mypy-clean, well-tested
Setup
pip install deepgram-sdk(7.x; Python 3.10–3.13).- Get a Deepgram API key from console.deepgram.com and export
DEEPGRAM_API_KEY(the client reads it automatically on construction; or passapi_key=explicitly). - Realtime STT:
client.listen.v2.connect(model="flux-general-en", encoding="linear16", sample_rate=16000), attachOPEN/MESSAGE/CLOSEhandlers,connection.start_listening(), then stream audio bytes. - File transcription:
client.listen.v1.media.transcribe_file(audio_bytes, model="nova-3", language="en"); TTS:client.speak.v1.audio.generate(text="...")and save the returned audio.
Prerequisites
Python 3.10+, a Deepgram API key (paid usage-based API; signup includes trial credits per vendor); network access to api.deepgram.com; ffmpeg or similar only if you need audio resampling client-side.
Use cases
Works with
Trust score — 8/10
Scored 8/10 (verified tier, metrics-v1). Evidence: 469 GitHub stars (log-scaled vs catalog peers); blended with ~3,166,523 monthly package downloads; last push 0d ago; 31 releases/12mo; 17 open issues. Manual review: client over paid metered API (zero offline value); trial-credit/pricing amounts unverified. License: MIT.
★ 469 GitHub stars
How the trust score is built
Full methodology →- Adoption · stars/downloads, log-scaled vs peers
- 6.6/10
- Maintenance · recency, releases, issue load
- 8.6/10
- Openness · license + docs
- 10.0/10
- Manual review · sanity read + red-flag check
- 8.0/10
- · 469 GitHub stars (log-scaled vs catalog peers)
- · blended with ~3,166,523 monthly package downloads
- · last push 0d ago; 31 releases/12mo; 17 open issues
- · manual review: client over paid metered API (zero offline value); trial-credit/pricing amounts unverified
Sources
Every fact above was checked against these sources. Where a claim comes from the provider and couldn't be independently verified, the text says so.