Audio
Text to Speech
Convert text to spoken audio (returns MP3 binary).
POST
/
api
/
v1
/
audio
/
tts
Text to Speech
curl --request POST \
--url https://api.example.com/api/v1/audio/tts \
--header 'Content-Type: application/json' \
--data '
{
"text": "<string>",
"voice": "<string>",
"speed": 123
}
'import requests
url = "https://api.example.com/api/v1/audio/tts"
payload = {
"text": "<string>",
"voice": "<string>",
"speed": 123
}
headers = {"Content-Type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({text: '<string>', voice: '<string>', speed: 123})
};
fetch('https://api.example.com/api/v1/audio/tts', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.example.com/api/v1/audio/tts",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'text' => '<string>',
'voice' => '<string>',
'speed' => 123
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.example.com/api/v1/audio/tts"
payload := strings.NewReader("{\n \"text\": \"<string>\",\n \"voice\": \"<string>\",\n \"speed\": 123\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.example.com/api/v1/audio/tts")
.header("Content-Type", "application/json")
.body("{\n \"text\": \"<string>\",\n \"voice\": \"<string>\",\n \"speed\": 123\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.example.com/api/v1/audio/tts")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n \"text\": \"<string>\",\n \"voice\": \"<string>\",\n \"speed\": 123\n}"
response = http.request(request)
puts response.read_bodyConvert text to speech. Returns raw audio bytes (
audio/mpeg) — not JSON.
The response is a binary MP3 file, not a JSON object. The
Content-Type header is audio/mpeg.Authentication
Requires a Bearer token. See Authentication.Request Body
Text to convert to speech. Maximum 4,096 characters.
Optional Theo voice identifier. Omit to use the default voice. Unknown values fall back to
theo-voice-classic.| Voice | Character |
|---|---|
theo-voice-classic | Neutral, versatile — default |
theo-voice-bright | Bright, clear, upbeat |
theo-voice-storyteller | Narrative, expressive |
theo-voice-deep | Deep, authoritative |
theo-voice-warm | Warm, professional |
theo-voice-soft | Soft, thoughtful |
Playback speed multiplier (0.25–4.0).
Request Examples
curl -X POST https://www.hitheo.ai/api/v1/audio/tts \
-H "Authorization: Bearer $THEO_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"text": "Welcome to Theo. How can I help you today?",
"voice": "theo-voice-warm",
"speed": 1.0
}' \
--output speech.mp3
const audioBuffer = await theo.tts({
text: "Welcome to Theo. How can I help you today?",
voice: "theo-voice-warm",
speed: 1.0,
});
// audioBuffer is an ArrayBuffer — write to file or stream to client
import { writeFileSync } from "fs";
writeFileSync("output.mp3", Buffer.from(audioBuffer));
Response
The response body is raw MP3 audio bytes.| Header | Value |
|---|---|
Content-Type | audio/mpeg |
Content-Length | File size in bytes |
X-Request-Id | Unique request ID (prefixed tts_) |
Errors
| Status | Code | Description |
|---|---|---|
| 400 | missing_text | text is required |
| 401 | invalid_api_key | Missing or invalid API key |
| 502 | tts_provider_error | Theo voice engine returned an error — retry |
| 503 | tts_unavailable | TTS is not configured on this instance |
Was this page helpful?
⌘I
Text to Speech
curl --request POST \
--url https://api.example.com/api/v1/audio/tts \
--header 'Content-Type: application/json' \
--data '
{
"text": "<string>",
"voice": "<string>",
"speed": 123
}
'import requests
url = "https://api.example.com/api/v1/audio/tts"
payload = {
"text": "<string>",
"voice": "<string>",
"speed": 123
}
headers = {"Content-Type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({text: '<string>', voice: '<string>', speed: 123})
};
fetch('https://api.example.com/api/v1/audio/tts', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.example.com/api/v1/audio/tts",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'text' => '<string>',
'voice' => '<string>',
'speed' => 123
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.example.com/api/v1/audio/tts"
payload := strings.NewReader("{\n \"text\": \"<string>\",\n \"voice\": \"<string>\",\n \"speed\": 123\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.example.com/api/v1/audio/tts")
.header("Content-Type", "application/json")
.body("{\n \"text\": \"<string>\",\n \"voice\": \"<string>\",\n \"speed\": 123\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.example.com/api/v1/audio/tts")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n \"text\": \"<string>\",\n \"voice\": \"<string>\",\n \"speed\": 123\n}"
response = http.request(request)
puts response.read_body