CLI
Check your setup, transcribe a file, synthesize speech, list voices and sessions, and run an MCP server from the command line.
The voiceai-sdk package ships a CLI. Run it with npx. It uses the same adapters and the same environment variables as your code, so it is a quick way to check a key or try a provider before you write any code.
npx voiceai-sdk doctorInstall voiceai-sdk in your project first. npx then runs the version your code uses, instead of downloading another one.
Commands
doctor
Checks your Node version, which provider keys it can see, and whether whisper-cli and piper are on PATH. It prints one line per provider and exits with 1 if a provider you configured can't connect.
transcribe
Transcribes an audio file with one provider and prints the text. With --json it prints the whole result, including words, language and durationMs.
npx voiceai-sdk transcribe call.wav --provider deepgram
npx voiceai-sdk transcribe call.wav --provider deepgram --json > call.json
# No account needed: whisper.cpp on your machine
npx voiceai-sdk transcribe call.wav --provider localIf the provider hears no speech, the result has ok: false. The command prints the reason and exits with 1.
say
Speaks text with one provider and writes the audio to the file you name with --out. This example picks the first voice from voices, then speaks with it:
VOICE_ID=$(npx voiceai-sdk voices --provider elevenlabs --json | jq -r '.[0].id')
npx voiceai-sdk say "Hello" --provider elevenlabs --voice "$VOICE_ID" --out hello.wavvoices
Lists the voices a provider offers: id, name, language, and gender where the provider reports it. It is listVoices from the command line.
npx voiceai-sdk voices --provider cartesiasessions list
Lists a provider's live sessions with their id, key, start time and state. It is listSessions from the command line.
npx voiceai-sdk sessions list --provider openaiFlags
| Flag | Used by | What it does |
|---|---|---|
--provider <name> | transcribe, say, voices, sessions list, mcp | The provider, by its subpath name: openai, deepgram, elevenlabs, cartesia, assemblyai, google, azure, aws, gladia, speechmatics, rime, local or mock. Required. |
--voice <id> | say | The voice to speak with. Leave it out to use the provider's default voice. |
--out <file> | say | Where to write the audio. Required. |
--json | doctor, transcribe, voices, sessions list | Print JSON instead of text, for scripts. |
Errors print to stderr, so stdout holds only the command's output. That keeps --json output safe to pipe into another tool.
Credentials
The CLI reads keys from the environment, the same variables the adapters read. No flag takes a key, so keys don't end up in your shell history.
| Provider | Variables |
|---|---|
openai | OPENAI_API_KEY |
deepgram | DEEPGRAM_API_KEY |
elevenlabs | ELEVENLABS_API_KEY |
cartesia | CARTESIA_API_KEY |
assemblyai | ASSEMBLYAI_API_KEY |
google | GOOGLE_APPLICATION_CREDENTIALS |
azure | AZURE_SPEECH_KEY, AZURE_SPEECH_REGION |
aws | AWS credentials, AWS_REGION |
gladia | GLADIA_API_KEY |
speechmatics | SPEECHMATICS_API_KEY |
rime | RIME_API_KEY |
local, mock | None |
google, azure and aws also need the vendor SDKs installed next to voiceai-sdk. See Install.
Exit codes
| Code | Meaning |
|---|---|
0 | The command succeeded. |
1 | The command ran and failed: a provider or network error, a missing or rejected key, or a transcription with ok: false. |
2 | Usage error: an unknown command, an unknown flag, or a missing required flag. |
Use the exit code to stop a script or a CI job early:
npx voiceai-sdk doctor || exit 1
npx voiceai-sdk transcribe fixtures/hello.wav --provider deepgram --json > out.jsonMCP server
npx voiceai-sdk mcp runs an MCP server over stdio. It exposes the same tools as voiceTools: speak, listen, transcribe and end_call. Your MCP client starts the command and talks to it over stdin and stdout, so you don't run it by hand.
npx voiceai-sdk mcp --provider deepgramThe server reads keys from its own environment, so set them in your MCP client's server config. See MCP for client setup and Agent tools for each tool's inputs and outputs.