curl --request POST \
--url 'https://api.elkapi.com/v1/audio/speech' \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '{
"model": "tts-1",
"input": "The weather is great today, perfect for a walk.",
"voice": "alloy",
"response_format": "mp3"
}'
import requests
url = "https://api.elkapi.com/v1/audio/speech"
headers = {
"Authorization": "Bearer <token>"
}
headers["Content-Type"] = "application/json"
payload = {
"model": "tts-1",
"input": "The weather is great today, perfect for a walk.",
"voice": "alloy",
"response_format": "mp3"
}
response = requests.request("POST", url, headers=headers, json=payload)
print(response.json())
const url = "https://api.elkapi.com/v1/audio/speech";
const headers = {
"Authorization": "Bearer <token>"
};
headers["Content-Type"] = "application/json";
const payload = {
"model": "tts-1",
"input": "The weather is great today, perfect for a walk.",
"voice": "alloy",
"response_format": "mp3"
};
const response = await fetch(url, {
method: "POST",
headers,
body: JSON.stringify(payload)
});
console.log(await response.json());
"string"
Native OpenAI Format
Text to Speech
- Convert text to audio
POST
/
v1
/
audio
/
speech
curl --request POST \
--url 'https://api.elkapi.com/v1/audio/speech' \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '{
"model": "tts-1",
"input": "The weather is great today, perfect for a walk.",
"voice": "alloy",
"response_format": "mp3"
}'
import requests
url = "https://api.elkapi.com/v1/audio/speech"
headers = {
"Authorization": "Bearer <token>"
}
headers["Content-Type"] = "application/json"
payload = {
"model": "tts-1",
"input": "The weather is great today, perfect for a walk.",
"voice": "alloy",
"response_format": "mp3"
}
response = requests.request("POST", url, headers=headers, json=payload)
print(response.json())
const url = "https://api.elkapi.com/v1/audio/speech";
const headers = {
"Authorization": "Bearer <token>"
};
headers["Content-Type"] = "application/json";
const payload = {
"model": "tts-1",
"input": "The weather is great today, perfect for a walk.",
"voice": "alloy",
"response_format": "mp3"
};
const response = await fetch(url, {
method: "POST",
headers,
body: JSON.stringify(payload)
});
console.log(await response.json());
"string"
curl --request POST \
--url 'https://api.elkapi.com/v1/audio/speech' \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '{
"model": "tts-1",
"input": "The weather is great today, perfect for a walk.",
"voice": "alloy",
"response_format": "mp3"
}'
import requests
url = "https://api.elkapi.com/v1/audio/speech"
headers = {
"Authorization": "Bearer <token>"
}
headers["Content-Type"] = "application/json"
payload = {
"model": "tts-1",
"input": "The weather is great today, perfect for a walk.",
"voice": "alloy",
"response_format": "mp3"
}
response = requests.request("POST", url, headers=headers, json=payload)
print(response.json())
const url = "https://api.elkapi.com/v1/audio/speech";
const headers = {
"Authorization": "Bearer <token>"
};
headers["Content-Type"] = "application/json";
const payload = {
"model": "tts-1",
"input": "The weather is great today, perfect for a walk.",
"voice": "alloy",
"response_format": "mp3"
};
const response = await fetch(url, {
method: "POST",
headers,
body: JSON.stringify(payload)
});
console.log(await response.json());
"string"
Authorizations
string
required
All endpoints require Bearer Token authentication.Add it to the request headers:
Authorization: Bearer YOUR_API_KEY
Body
string
default:"tts-1"
required
Example:
tts-1string
required
Text to convert
string
required
Allowed values:
alloy, echo, fable, onyx, nova, shimmerstring
default:"mp3"
Allowed values:
mp3, opus, aac, flac, wav, pcmnumber
default:"1"
⌘I