On this page

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.

Bash
npx voiceai-sdk doctor

Install 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.

Bash
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 local

If 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:

Bash
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.wav

voices

Lists the voices a provider offers: id, name, language, and gender where the provider reports it. It is listVoices from the command line.

Bash
npx voiceai-sdk voices --provider cartesia

sessions list

Lists a provider's live sessions with their id, key, start time and state. It is listSessions from the command line.

Bash
npx voiceai-sdk sessions list --provider openai

Flags

FlagUsed byWhat it does
--provider <name>transcribe, say, voices, sessions list, mcpThe provider, by its subpath name: openai, deepgram, elevenlabs, cartesia, assemblyai, google, azure, aws, gladia, speechmatics, rime, local or mock. Required.
--voice <id>sayThe voice to speak with. Leave it out to use the provider's default voice.
--out <file>sayWhere to write the audio. Required.
--jsondoctor, transcribe, voices, sessions listPrint 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.

ProviderVariables
openaiOPENAI_API_KEY
deepgramDEEPGRAM_API_KEY
elevenlabsELEVENLABS_API_KEY
cartesiaCARTESIA_API_KEY
assemblyaiASSEMBLYAI_API_KEY
googleGOOGLE_APPLICATION_CREDENTIALS
azureAZURE_SPEECH_KEY, AZURE_SPEECH_REGION
awsAWS credentials, AWS_REGION
gladiaGLADIA_API_KEY
speechmaticsSPEECHMATICS_API_KEY
rimeRIME_API_KEY
local, mockNone

google, azure and aws also need the vendor SDKs installed next to voiceai-sdk. See Install.

Exit codes

CodeMeaning
0The command succeeded.
1The command ran and failed: a provider or network error, a missing or rejected key, or a transcription with ok: false.
2Usage 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:

Bash
npx voiceai-sdk doctor || exit 1
npx voiceai-sdk transcribe fixtures/hello.wav --provider deepgram --json > out.json

MCP 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.

Bash
npx voiceai-sdk mcp --provider deepgram

The 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.

Was this page helpful?

Esc

Loading…

↑↓ navigate openCtrl J preview