Skip to content
Dashboard

Grok STT

Grok STT is xAI's speech-to-text model. It transcribes recorded audio into text across 25 languages, available through Vercel AI Gateway with the AI SDK.

Websockets
index.ts
import { experimental_streamTranscribe as streamTranscribe } from 'ai';
import { createGateway, gateway } from '@ai-sdk/gateway';
import { readFile } from 'node:fs/promises';
const modelId = 'xai/grok-stt';
// Mint this on your server, then send only the short-lived token to the client.
const { token } = await gateway.experimental_transcription.getToken({
model: modelId,
});
const clientGateway = createGateway({ apiKey: token });
// Raw 24 kHz, 16-bit signed little-endian mono PCM audio.
const bytes = await readFile('audio.pcm');
const audio = new ReadableStream<Uint8Array>({
start(controller) {
controller.enqueue(new Uint8Array(bytes));
controller.close();
},
});
const result = streamTranscribe({
model: clientGateway.transcription(modelId),
audio,
inputAudioFormat: { type: 'audio/pcm', rate: 24000 },
});
for await (const part of result.fullStream) {
if (part.type === 'transcript-delta') {
process.stdout.write(part.delta);
}
}
console.log('\nFinal:', await result.text);

Frequently Asked Questions

  • How many languages does Grok STT support?

    Grok STT transcribes audio in 25 languages, with the detected language returned alongside the transcript.

  • How do I transcribe audio with Grok STT?

    Use the AI SDK's experimental_transcribe function with audio as a Buffer, Uint8Array, base64 string, or URL. A REST endpoint also accepts base64-encoded audio if you're not using the AI SDK.

  • What does the transcription result include?

    The result includes the full transcript text, the detected language, the audio duration in seconds, timestamped segments when available, and any provider warnings.

  • Does Grok STT stream transcription results through AI Gateway?

    No. The full transcript returns in a single response. For live, two-way voice, use grok-voice-think-fast-1.0 instead.

  • What does Grok STT cost?

    Billing is based on audio duration. See the pricing panel on this page for current rates.

  • How do I authenticate with Grok STT through Vercel AI Gateway?

    Use your Vercel AI Gateway API key with xai/grok-stt as the model identifier. AI Gateway handles provider routing automatically.

  • Does Vercel AI Gateway support Zero Data Retention for Grok STT?

    Zero Data Retention is not currently available for this model. Zero Data Retention is offered on a per-provider basis. See https://vercel.com/docs/ai-gateway/capabilities/zdr for details.