curl --request POST \
--url https://api.cartesia.ai/tts/bytes \
--header 'Authorization: Bearer <token>' \
--header 'Cartesia-Version: <cartesia-version>' \
--header 'Content-Type: application/json' \
--data @- <<EOF
{
"model_id": "sonic-3.5",
"transcript": "Hi there, it's awesome to meet you.",
"voice": {
"mode": "id",
"id": "db6b0ed5-d5d3-463d-ae85-518a07d3c2b4"
},
"output_format": {
"container": "wav",
"encoding": "pcm_s16le",
"sample_rate": 44100
},
"pronunciation_dict_id": "<string>",
"generation_config": {
"volume": 1,
"speed": 1
},
"speed": "normal"
}
EOFimport requests
url = "https://api.cartesia.ai/tts/bytes"
payload = {
"model_id": "sonic-3.5",
"transcript": "Hi there, it's awesome to meet you.",
"voice": {
"mode": "id",
"id": "db6b0ed5-d5d3-463d-ae85-518a07d3c2b4"
},
"output_format": {
"container": "wav",
"encoding": "pcm_s16le",
"sample_rate": 44100
},
"pronunciation_dict_id": "<string>",
"generation_config": {
"volume": 1,
"speed": 1
},
"speed": "normal"
}
headers = {
"Cartesia-Version": "<cartesia-version>",
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {
'Cartesia-Version': '<cartesia-version>',
Authorization: 'Bearer <token>',
'Content-Type': 'application/json'
},
body: JSON.stringify({
model_id: 'sonic-3.5',
transcript: 'Hi there, it\'s awesome to meet you.',
voice: {mode: 'id', id: 'db6b0ed5-d5d3-463d-ae85-518a07d3c2b4'},
output_format: {container: 'wav', encoding: 'pcm_s16le', sample_rate: 44100},
pronunciation_dict_id: '<string>',
generation_config: {volume: 1, speed: 1},
speed: 'normal'
})
};
fetch('https://api.cartesia.ai/tts/bytes', 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.cartesia.ai/tts/bytes",
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([
'model_id' => 'sonic-3.5',
'transcript' => 'Hi there, it\'s awesome to meet you.',
'voice' => [
'mode' => 'id',
'id' => 'db6b0ed5-d5d3-463d-ae85-518a07d3c2b4'
],
'output_format' => [
'container' => 'wav',
'encoding' => 'pcm_s16le',
'sample_rate' => 44100
],
'pronunciation_dict_id' => '<string>',
'generation_config' => [
'volume' => 1,
'speed' => 1
],
'speed' => 'normal'
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Cartesia-Version: <cartesia-version>",
"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.cartesia.ai/tts/bytes"
payload := strings.NewReader("{\n \"model_id\": \"sonic-3.5\",\n \"transcript\": \"Hi there, it's awesome to meet you.\",\n \"voice\": {\n \"mode\": \"id\",\n \"id\": \"db6b0ed5-d5d3-463d-ae85-518a07d3c2b4\"\n },\n \"output_format\": {\n \"container\": \"wav\",\n \"encoding\": \"pcm_s16le\",\n \"sample_rate\": 44100\n },\n \"pronunciation_dict_id\": \"<string>\",\n \"generation_config\": {\n \"volume\": 1,\n \"speed\": 1\n },\n \"speed\": \"normal\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Cartesia-Version", "<cartesia-version>")
req.Header.Add("Authorization", "Bearer <token>")
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.cartesia.ai/tts/bytes")
.header("Cartesia-Version", "<cartesia-version>")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"model_id\": \"sonic-3.5\",\n \"transcript\": \"Hi there, it's awesome to meet you.\",\n \"voice\": {\n \"mode\": \"id\",\n \"id\": \"db6b0ed5-d5d3-463d-ae85-518a07d3c2b4\"\n },\n \"output_format\": {\n \"container\": \"wav\",\n \"encoding\": \"pcm_s16le\",\n \"sample_rate\": 44100\n },\n \"pronunciation_dict_id\": \"<string>\",\n \"generation_config\": {\n \"volume\": 1,\n \"speed\": 1\n },\n \"speed\": \"normal\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.cartesia.ai/tts/bytes")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Cartesia-Version"] = '<cartesia-version>'
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"model_id\": \"sonic-3.5\",\n \"transcript\": \"Hi there, it's awesome to meet you.\",\n \"voice\": {\n \"mode\": \"id\",\n \"id\": \"db6b0ed5-d5d3-463d-ae85-518a07d3c2b4\"\n },\n \"output_format\": {\n \"container\": \"wav\",\n \"encoding\": \"pcm_s16le\",\n \"sample_rate\": 44100\n },\n \"pronunciation_dict_id\": \"<string>\",\n \"generation_config\": {\n \"volume\": 1,\n \"speed\": 1\n },\n \"speed\": \"normal\"\n}"
response = http.request(request)
puts response.read_body"<string>"Text-to-Speech (Bytes)
Stream audio from a complete transcript
curl --request POST \
--url https://api.cartesia.ai/tts/bytes \
--header 'Authorization: Bearer <token>' \
--header 'Cartesia-Version: <cartesia-version>' \
--header 'Content-Type: application/json' \
--data @- <<EOF
{
"model_id": "sonic-3.5",
"transcript": "Hi there, it's awesome to meet you.",
"voice": {
"mode": "id",
"id": "db6b0ed5-d5d3-463d-ae85-518a07d3c2b4"
},
"output_format": {
"container": "wav",
"encoding": "pcm_s16le",
"sample_rate": 44100
},
"pronunciation_dict_id": "<string>",
"generation_config": {
"volume": 1,
"speed": 1
},
"speed": "normal"
}
EOFimport requests
url = "https://api.cartesia.ai/tts/bytes"
payload = {
"model_id": "sonic-3.5",
"transcript": "Hi there, it's awesome to meet you.",
"voice": {
"mode": "id",
"id": "db6b0ed5-d5d3-463d-ae85-518a07d3c2b4"
},
"output_format": {
"container": "wav",
"encoding": "pcm_s16le",
"sample_rate": 44100
},
"pronunciation_dict_id": "<string>",
"generation_config": {
"volume": 1,
"speed": 1
},
"speed": "normal"
}
headers = {
"Cartesia-Version": "<cartesia-version>",
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {
'Cartesia-Version': '<cartesia-version>',
Authorization: 'Bearer <token>',
'Content-Type': 'application/json'
},
body: JSON.stringify({
model_id: 'sonic-3.5',
transcript: 'Hi there, it\'s awesome to meet you.',
voice: {mode: 'id', id: 'db6b0ed5-d5d3-463d-ae85-518a07d3c2b4'},
output_format: {container: 'wav', encoding: 'pcm_s16le', sample_rate: 44100},
pronunciation_dict_id: '<string>',
generation_config: {volume: 1, speed: 1},
speed: 'normal'
})
};
fetch('https://api.cartesia.ai/tts/bytes', 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.cartesia.ai/tts/bytes",
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([
'model_id' => 'sonic-3.5',
'transcript' => 'Hi there, it\'s awesome to meet you.',
'voice' => [
'mode' => 'id',
'id' => 'db6b0ed5-d5d3-463d-ae85-518a07d3c2b4'
],
'output_format' => [
'container' => 'wav',
'encoding' => 'pcm_s16le',
'sample_rate' => 44100
],
'pronunciation_dict_id' => '<string>',
'generation_config' => [
'volume' => 1,
'speed' => 1
],
'speed' => 'normal'
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Cartesia-Version: <cartesia-version>",
"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.cartesia.ai/tts/bytes"
payload := strings.NewReader("{\n \"model_id\": \"sonic-3.5\",\n \"transcript\": \"Hi there, it's awesome to meet you.\",\n \"voice\": {\n \"mode\": \"id\",\n \"id\": \"db6b0ed5-d5d3-463d-ae85-518a07d3c2b4\"\n },\n \"output_format\": {\n \"container\": \"wav\",\n \"encoding\": \"pcm_s16le\",\n \"sample_rate\": 44100\n },\n \"pronunciation_dict_id\": \"<string>\",\n \"generation_config\": {\n \"volume\": 1,\n \"speed\": 1\n },\n \"speed\": \"normal\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Cartesia-Version", "<cartesia-version>")
req.Header.Add("Authorization", "Bearer <token>")
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.cartesia.ai/tts/bytes")
.header("Cartesia-Version", "<cartesia-version>")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"model_id\": \"sonic-3.5\",\n \"transcript\": \"Hi there, it's awesome to meet you.\",\n \"voice\": {\n \"mode\": \"id\",\n \"id\": \"db6b0ed5-d5d3-463d-ae85-518a07d3c2b4\"\n },\n \"output_format\": {\n \"container\": \"wav\",\n \"encoding\": \"pcm_s16le\",\n \"sample_rate\": 44100\n },\n \"pronunciation_dict_id\": \"<string>\",\n \"generation_config\": {\n \"volume\": 1,\n \"speed\": 1\n },\n \"speed\": \"normal\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.cartesia.ai/tts/bytes")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Cartesia-Version"] = '<cartesia-version>'
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"model_id\": \"sonic-3.5\",\n \"transcript\": \"Hi there, it's awesome to meet you.\",\n \"voice\": {\n \"mode\": \"id\",\n \"id\": \"db6b0ed5-d5d3-463d-ae85-518a07d3c2b4\"\n },\n \"output_format\": {\n \"container\": \"wav\",\n \"encoding\": \"pcm_s16le\",\n \"sample_rate\": 44100\n },\n \"pronunciation_dict_id\": \"<string>\",\n \"generation_config\": {\n \"volume\": 1,\n \"speed\": 1\n },\n \"speed\": \"normal\"\n}"
response = http.request(request)
puts response.read_body"<string>"Authorizations
Cartesia API key (sk_car_...). Get one at play.cartesia.ai/keys.
Headers
API version header.
2026-03-01 "2026-03-01"
Body
Show child attributes
Show child attributes
- WAVOutputFormat
- MP3OutputFormat
- RAWOutputFormat
Show child attributes
Show child attributes
The language that the given voice should speak the transcript in. This may depend on the model you're using. See Models for details.
en, fr, de, es, pt, zh, ja, hi, it, ko, nl, pl, ru, sv, tr, tl, bg, ro, ar, cs, el, fi, hr, ms, sk, da, ta, uk, hu, no, vi, bn, th, he, ka, id, te, gu, kn, ml, mr, pa The ID of a pronunciation dictionary to use for the generation. Pronunciation dictionaries are supported by sonic-3 models and newer.
Configure the various attributes of the generated speech. Available on sonic-3 and sonic-3.5; not available on earlier models.
See Volume, Speed, and Emotion for a guide on this option.
Show child attributes
Show child attributes
This property is deprecated and may not work for all voices. Use generation_config.speed instead.
Influences the speed of the generated speech.
slow, normal, fast Response
Audio bytes
The response is of type file.
Was this page helpful?