POST/v1/audio/speech

Generate speech from text

Convert text input to speech audio. The response may be raw audio bytes (audio/mpeg, audio/wav, and similar) or a JSON envelope with base64-encoded audio in data[].b64_json.

  • IdempotentThe SDK sends Idempotency-Key, so a retried request is only applied once.

5 body fields
modelstringrequired
The text-to-speech model to use.
inputstringrequired
The text to convert to speech.
voicestringoptional
The voice to use for synthesis.
response_formatstringoptional
The audio format to return. Supported values include `mp3` and `wav`. The API may return raw audio bytes or a JSON envelope with base64-encoded audio.
instructionsstringoptional
Optional style or delivery instructions for the synthesizer.

5 status codes
200Successful speech generation.
createdintegeroptional
Unix timestamp (in seconds) of when the audio was created.
dataarray<object>required
Generated audio items.
401Authentication failed due to invalid credentials.
idstringrequired
A short identifier corresponding to the HTTP status code returned. For example, the ID for a response returning a 404 status code would be "not_found."
messagestringrequired
A message providing additional information about the error, including details to help resolve it when possible.
request_idstringoptional
Optionally, some endpoints may include a request ID that should be provided when reporting bugs or opening support tickets to help identify the issue.
429The API rate limit has been exceeded.
idstringrequired
A short identifier corresponding to the HTTP status code returned. For example, the ID for a response returning a 404 status code would be "not_found."
messagestringrequired
A message providing additional information about the error, including details to help resolve it when possible.
request_idstringoptional
Optionally, some endpoints may include a request ID that should be provided when reporting bugs or opening support tickets to help identify the issue.
500There was a server error.
idstringrequired
A short identifier corresponding to the HTTP status code returned. For example, the ID for a response returning a 404 status code would be "not_found."
messagestringrequired
A message providing additional information about the error, including details to help resolve it when possible.
request_idstringoptional
Optionally, some endpoints may include a request ID that should be provided when reporting bugs or opening support tickets to help identify the issue.
defaultThere was an unexpected error.
idstringrequired
A short identifier corresponding to the HTTP status code returned. For example, the ID for a response returning a 404 status code would be "not_found."
messagestringrequired
A message providing additional information about the error, including details to help resolve it when possible.
request_idstringoptional
Optionally, some endpoints may include a request ID that should be provided when reporting bugs or opening support tickets to help identify the issue.

Error handling

A 401 is returned: Authentication failed due to invalid credentials. A 429 is returned: The API rate limit has been exceeded. A 500 is returned: There was a server error. Any other status is an error: There was an unexpected error.