Provide your bearer token in the Authorization header when making requests to protected resources. Example: Authorization: Bearer ********************
Example:
Bearer {{YOUR_API_KEY}}
Body Params application/json
model
string
required
One of the available TTS models: tts-1 or tts-1-hd
input
string
required
To generate audio text. The maximum length is 4096 characters.
voice
string
required
The speech used when generating audio. The supported voices include: alloy, echo, fable, onyx, nova, and shim.
response_format
string
optional
文件 图片 41/10000 实时翻译 划译 The default format is MP3 audio. The supported formats are: mp3, opus, aac, and flac.
speed
number
optional
The default generated audio speed is 1. Choose a value between 0.25 and 4.0. 1.0 is the default value.
Example
{"model":"tts","input":"The quick brown fox jumped over the lazy dog.","voice":"alloy"}
Request samples
Shell
JavaScript
Java
Swift
Go
PHP
Python
HTTP
C
C#
Objective-C
Ruby
OCaml
Dart
R
Request Request Example
Shell
JavaScript
Java
Swift
curl--location-g--request POST '{{BASE_URL}}/v1/audio/speech' \
--header'Authorization: Bearer {{YOUR_API_KEY}}' \
--header'Content-Type: application/json' \
--data-raw'{
"model": "tts",
"input": "The quick brown fox jumped over the lazy dog.",
"voice": "alloy"
}'