Deepgram CLI — Getting Started
Deepgram CLI — Getting Started
Transcribe audio, synthesize speech, and manage your Deepgram account — all from your terminal.
The dg CLI gives you full access to Deepgram APIs from your terminal. Transcribe files, stream live audio, synthesize speech, analyze text, and manage your Deepgram account — without writing a single line of code.
Prerequisites
- Python 3.10 or later
- A Deepgram API key (get one free)
Quick Start
Core Workflows
Transcribe audio
Text-to-speech
Text intelligence
Account management
Account commands are flag-based. Run dg keys --help or dg projects --help for the full set.
Output Formats
The CLI defaults to human-readable output in the terminal. Use -o or --output to switch formats:
-o belongs to dg itself, so it goes before the subcommand name. After the subcommand it fails to parse — dg listen audio.mp3 -o json exits 1 with Error: No such option '-o'. On dg speak the collision is quieter: there, a bare -o is the output file path, not a format.
Agent-friendly mode selects JSON on its own, without -o. A piped stdout alone does not trigger it.
Usage errors, cancellation messages, and progress output go to stderr rather than stdout, so redirecting stderr leaves stdout carrying the payload:
Some command-level errors still print to stdout — an authentication failure is the common one — so check the exit code rather than assuming stdout parses.
Exit Codes
Every command reports its outcome through the exit code, so scripts and CI steps can branch on it:
Exit codes are enforced as of CLI 0.3.0. Earlier versions exited 0 regardless of outcome, so a pipeline that ignored the exit code may begin surfacing failures it previously swallowed. No command that succeeds changes its exit code.
Agent-Friendly Mode
The CLI auto-detects AI agent environments (Claude Code, Aider, OpenAI Codex, Gemini) and adjusts its behavior:
- Disables interactive prompts
- Defaults to JSON output
- Routes status messages and warnings to stderr
To force the mode on:
--agent-friendly does something different on a subcommand: it prints that command’s parameter documentation as JSON and exits without running it.
Next Steps
- Install the CLI — More installation methods including pip, pipx, and Homebrew
- Authenticate — Learn about authentication options
- Speech-to-Text — Full transcription reference
- Text-to-Speech — Full TTS reference