curl --request POST \
--url https://api.opper.ai/v3/audio/speech \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"input": "<string>",
"model": "<string>"
}
'import requests
url = "https://api.opper.ai/v3/audio/speech"
payload = {
"input": "<string>",
"model": "<string>"
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({input: '<string>', model: '<string>'})
};
fetch('https://api.opper.ai/v3/audio/speech', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));{
"audio": {
"b64_json": "<string>",
"file_id": "<string>",
"mime_type": "<string>",
"url": "<string>"
},
"created": 123,
"id": "<string>",
"model": "<string>",
"usage": {
"characters": 123,
"cost": 123
}
}{
"error": {
"code": "<string>",
"message": "<string>",
"details": "<unknown>"
},
"meta": {}
}{
"error": {
"code": "<string>",
"message": "<string>",
"details": "<unknown>"
},
"meta": {}
}Generate speech
Convert text to spoken audio synchronously and get it back inline as base64. model and input are required; voice, format (mp3 default; response_format is accepted as an alias, and a response_format that is not an audio format, such as b64_json, is ignored), and speed are normalized and validated against the model’s declared capabilities, and everything in parameters is forwarded verbatim to the provider. Set store: true to also save the output to /v3/files and get a reusable file_id; nothing is stored otherwise. Send Accept: application/octet-stream (or an audio/* type, without application/json) to get the audio bytes as the response body instead, typed by Content-Type, as the OpenAI SDKs expect; POST /v3/compat/audio/speech always answers that way.
curl --request POST \
--url https://api.opper.ai/v3/audio/speech \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"input": "<string>",
"model": "<string>"
}
'import requests
url = "https://api.opper.ai/v3/audio/speech"
payload = {
"input": "<string>",
"model": "<string>"
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({input: '<string>', model: '<string>'})
};
fetch('https://api.opper.ai/v3/audio/speech', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));{
"audio": {
"b64_json": "<string>",
"file_id": "<string>",
"mime_type": "<string>",
"url": "<string>"
},
"created": 123,
"id": "<string>",
"model": "<string>",
"usage": {
"characters": 123,
"cost": 123
}
}{
"error": {
"code": "<string>",
"message": "<string>",
"details": "<unknown>"
},
"meta": {}
}{
"error": {
"code": "<string>",
"message": "<string>",
"details": "<unknown>"
},
"meta": {}
}Authorizations
API key authentication. Pass your API key as a Bearer token.
Body
Alias of format (OpenAI's name for it). If both are sent they must match. On /v3/audio/speech a value that is not an audio format (e.g. b64_json) is ignored; the compat route rejects it.
Persist the generated audio to /v3/files and return a reusable file_id. Defaults to false; set true to store.