API reference
Text to speech
OpenAI's speech request, answered with the audio itself. See the Voice guide for picking a voice.
POST
https://api.oneapi.id/v1/audio/speech- Key header
Authorization: Bearer- Answer
- The audio bytes, not JSON
- Billed
- Characters of
input, at the input price
Body fields
modelstring requiredA tts model from GET /v1/audio/models.
inputstring requiredThe text to speak.
voicestringA voice id from /v1/audio/voices. Omit it for the model's default voice.
languagestringA language hint such as id or en-GB. Without it the text is read as English.
response_formatstringwav (default), pcm or opus.
sample_rateintegerHertz, 8000 to 192000. Default 24000, which every model offers.
provider_optionsobjectA vendor's own settings, keyed by vendor: {"elevenlabs":{"stability":0.4}}.
Example
curl https://api.oneapi.id/v1/audio/speech \
-H "Authorization: Bearer $ONEAPI_API_KEY" \
-H "Content-Type: application/json" \
-d '{"model":"eleven_v4_turbo","input":"Halo.","language":"id"}' \
--output speech.wavResponse formats
| response_format | Content-Type | What you get |
|---|---|---|
wav | audio/wav | 16-bit mono PCM in a WAV file, ready to play |
pcm | audio/pcm;rate=24000 | The same samples with no header |
opus | audio/opus | Opus, on models that offer it |
Errors
Errors use the standard shape. A 400 also covers a model that is not a speech model, a response_format of mp3, and a speed other than 1.