Text to speech
POST
/audio/speech
const url = 'https://example.com/audio/speech';const options = { method: 'POST', headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'}, body: '{"input":"Hello there!","model":"tts-1","voice":"alloy"}'};
try { const response = await fetch(url, options); const data = await response.json(); console.log(data);} catch (error) { console.error(error);}curl --request POST \ --url https://example.com/audio/speech \ --header 'Authorization: Bearer <token>' \ --header 'Content-Type: application/json' \ --data '{ "input": "Hello there!", "model": "tts-1", "voice": "alloy" }'OpenAI-compatible TTS. Returns mp3 audio. Served by gpt-4o-mini-tts; OpenAI voices (alloy, echo, fable, nova, shimmer, …) are accepted. Charged per input characters.
Authorizations
Заголовок раздела «Authorizations»Request Bodyrequired
Заголовок раздела «Request Bodyrequired»Media typeapplication/json
SpeechRequest
object
Example
{ "input": "Hello there!", "model": "tts-1", "voice": "alloy"}Responses
Заголовок раздела «Responses»Successful Response
Media typeapplication/json
Examplegenerated
exampleValidation Error
Media typeapplication/json
HTTPValidationError
object
detail
Detail
Array<object>
ValidationErrorobject
loc
required
Location
Array
msg
required
Message
string
type
required
Error Type
string
input
Input
ctx
Context
object
Examplegenerated
{ "detail": [ { "loc": [ "example" ], "msg": "example", "type": "example", "input": "example", "ctx": {} } ]}