Transcribe audio with the Grok Voice API
Transcribe audio with the Grok Voice API
POST https://api.x.ai/v1/stt turns audio into text. Send multipart/form-data with either file or url (one is required). Put file last in the form. Get a key and credits at console.x.ai.
Unary call
curl -X POST https://api.x.ai/v1/stt \
-H "Authorization: Bearer $XAI_API_KEY" \
-F format=true \
-F language=en \
-F file=@audio.mp3
format=true needs language. That flag runs Inverse Text Normalization so spoken numbers come back in written form.
Limits and knobs
- Max file size: 500 MB.
- Containers auto-detected: wav, mp3, ogg, opus, flac, aac, mp4, m4a, mkv (MP3/AAC/FLAC inside mkv).
- Raw pcm / mulaw / alaw need
audio_formatplussample_rate. keytermbiases proper nouns (repeatable, max 100 terms, 50 chars each).filler_wordsdefaults tofalse(uh/um stripped).diarize=trueadds a speaker label per word.multichannel=truereturns channels.
Response shape
You get text, language (BCP-47), duration, and words as [{text, start, end}]. Optional speaker when diarize is on; optional channels when multichannel is on.
Streaming
Live audio uses wss://api.x.ai/v1/stt. Wait for transcript.created before sending binary frames, then finish with {"type":"audio.done"}. Never put the API key in the browser. Proxy the socket through your server.
Pitfalls
413means the file is over 500 MB.400whenformat=truewithoutlanguage.401on a bad or missing key.- Put
filelast. Fields after the file, or the file before other fields, may be ignored. - Console API credits are a separate bill from SuperGrok's weekly pool on grok.com.