Code snippetCodingIntermediate · 3 min

Use custom voice in xAI Text to Speech API

Pass the custom voice_id as the 'voice' query parameter in TTS API calls.

GrokVerbatim
Code
GET /v1/tts?voice=[[CUSTOM_VOICE_ID]]&text=Hello+world
Language

bash

Explanation

To use a custom voice, simply replace the built-in voice identifier with your custom voice_id in the 'voice' query parameter of the TTS API request.

What it does and when to use it

This example shows how to integrate a custom voice into Text to Speech API calls. The custom voice ID is passed as a query parameter, making it interchangeable with built-in voices.

Why it works

The API is designed to accept custom voice IDs in the same parameter as built-in voices, simplifying integration and allowing seamless switching between voice options.

Sources and credit

First seen on Subvolts Aug 3, 2026. Updated Sep 11, 2026. Spotted a problem? Tell us.

Where it shows up
Terms used

TTS

Related in the PlaybookPlaybook →

The Playbook: reusable how-tos, prompts, configs and tips pulled out of the news.

Questions people ask

Which AI tools does this work with?
The sources used it with Grok.
Where did this come from?
xAI (xAI Docs: Guides). Subvolts collected, normalized and credited it; the link above opens the original.