Grok TTS
Grok TTS is xAI's text-to-speech model with five expressive voices, speech tags, and telephony codec support, available through Vercel AI Gateway.
import { experimental_generateSpeech as generateSpeech } from 'ai';import { gateway } from '@ai-sdk/gateway';import { writeFile } from 'node:fs/promises';
const result = await generateSpeech({ model: gateway.speechModel('xai/grok-tts'), text: 'Hello from the Vercel AI Gateway!', voice: 'eve',});
await writeFile('speech.mp3', result.audio.uint8Array);Frequently Asked Questions
How many voices does Grok TTS offer?
Grok TTS offers five expressive voices, such as
eve. Set thevoiceoption ingenerateSpeechto choose one.What are speech tags in Grok TTS?
Speech tags are controls for expression and delivery in generated speech. Combined with the expressive voices, they let you adjust how Grok TTS reads your text.
What audio formats does Grok TTS support?
Set
outputFormatto a format likemp3orwav. Grok TTS also supports telephony codecs for phone-system audio, and unsupported options are reported inwarnings.How do I generate speech with Grok TTS?
Use the AI SDK's
experimental_generateSpeechfunction with your text, avoice, and anoutputFormat, then saveresult.audio.uint8Array. A REST endpoint returns base64-encoded audio if you're not using the AI SDK.What does Grok TTS cost?
Billing is per input character, so cost scales with text length. See the pricing panel on this page for current rates.
How do I authenticate with Grok TTS through Vercel AI Gateway?
Use your Vercel AI Gateway API key with
xai/grok-ttsas the model identifier. AI Gateway handles provider routing automatically.Does Vercel AI Gateway support Zero Data Retention for Grok TTS?
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.