Use speech tags in Text to Speech
Use speech tags in Text to Speech
Drop inline tags into the text you send to POST https://api.x.ai/v1/tts (or the streaming TTS WebSocket) for pauses, laughs, whispers, and other delivery cues. The tags stay in the request body; billing still counts the characters you send.
Inline vs wrapping
- Inline
[tag]— fires at that spot (pause, laugh, breath). - Wrapping
<tag>…</tag>— changes delivery for the enclosed phrase (whisper, sing, speed).
curl -X POST https://api.x.ai/v1/tts \
-H "Authorization: Bearer $XAI_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"text": "So I walked in and [pause] there it was. [laugh] I honestly could not believe it!",
"voice_id": "eve",
"language": "en"
}' \
--output expressive.mp3
curl -X POST https://api.x.ai/v1/tts \
-H "Authorization: Bearer $XAI_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"text": "I need to tell you something. <whisper>It is a secret.</whisper> Pretty cool, right?",
"voice_id": "eve",
"language": "en"
}' \
--output whisper.mp3
How to write them
- Place inline tags where a person would actually pause or laugh.
- Pair tags with punctuation:
"Really? [laugh] That's incredible!"lands better than a stack of bare tags. - Use
[pause]or[long-pause]when a beat needs to land. - Wrap complete phrases, not single words.
- Combine styles when you need them: a whispered line after a pause, then normal delivery.
Preview tags in the TTS playground at console.x.ai before you ship a script.
Pitfalls
- Unary
textmax is 15,000 characters including tags. Longer scripts go towss://api.x.ai/v1/tts. - With
with_timestamps: true,graph_charsincludes the tag characters. - Never call TTS from the browser with the long-lived API key. Proxy it.
- Console API credits are separate from SuperGrok's weekly pool on grok.com.