Text to speech
Synthesize speech from text with preset, designed, or cloned voices.
Text to speech takes a string and returns spoken audio through an API that follows the OpenAI speech shape. Pick a voice, send the text, and the response body is the audio itself. If you already call OpenAI for speech, change the base URL and the model.
Get an API key
Create a Sprag account and open API keys in the app to generate one.
Copy the key immediately. The full value is shown once and is not recoverable after you leave the page.
Export it as an environment variable, replacing the placeholder with your key:
export SPRAG_API_KEY=<your_sprag_api_key>Make a request
Point any OpenAI-compatible client at https://api.sprag.ai/v1 and set
model to chorus. The response body is the audio itself, not JSON.
curl https://api.sprag.ai/v1/audio/speech \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $SPRAG_API_KEY" \
-d '{
"model": "chorus",
"input": "The quarterly numbers are in and they look good.",
"voice": "marin",
"response_format": "mp3"
}' \
--output out.mp3Pick a voice
marin above is a preset voice. List the voices rather than hardcoding an id.
The set can change.
curl "https://api.sprag.ai/v1/audio/voices?model=chorus" \
-H "Authorization: Bearer $SPRAG_API_KEY"A voice comes from one of three sources, and the fields you send choose which:
| Send | Voice source |
|---|---|
voice with a preset id | A built-in speaker |
voice with the id of a designed voice | A voice created from a written description |
ref_audio and ref_text, or voice with the id of a cloned voice | A voice cloned from reference audio |
Design happens before the speech request. POST /v1/audio/voices/design
returns previews, and POST /v1/audio/voices creates a voice from one. The
voice's id goes in voice. Voices covers all three sources.
Where to go next
API. REST for text you already have, realtime for spoken conversation.
Voices. Presets, designed voices, and cloning.
Models. The speech models and the fields each one accepts.
Concepts. Language coverage and audio formats.