Subspace Institute

Cartesia TTS API

Generates speech audio from the provided text using Cartesia's Text-to-Speech service

POST
/tts-cartesia
textstring
Length1 <= length <= 10000
voice?string

The ID of the voice to use

Default"f9a4b3a6-b44b-469f-90e3-c8e19bd30e99"
model?string

The ID of the model to use for the generation

Default"sonic-2"
tokenstring

Cartesia API key for authentication

Length1 <= length
language?string

The language that the given voice should speak the transcript in

Default"zh"
Value in"en" | "fr" | "de" | "es" | "pt" | "zh" | "ja" | "hi" | "it" | "ko" | "nl" | "pl" | "ru" | "sv" | "tr"
duration?number

The maximum duration of the audio in seconds

Rangetrue < value
speed?string

Speed setting for the model

Default"normal"
Value in"slow" | "normal" | "fast"
pronunciation_dict_ids?array<string>

A list of pronunciation dict IDs to use for the generation

output_format?object & object & object

Audio output format configuration

Default{"container":"mp3","bit_rate":64000,"sample_rate":44100}

Response Body

curl -X POST "https://edge-workers.laplace.cn/laplace/tts-cartesia" \
  -H "Content-Type: application/json" \
  -d '{
    "text": "Hello, world!",
    "token": "string"
  }'
const body = JSON.stringify({
  "text": "Hello, world!",
  "token": "string"
})

fetch("https://edge-workers.laplace.cn/laplace/tts-cartesia", {
  body
})
package main

import (
  "fmt"
  "net/http"
  "io/ioutil"
  "strings"
)

func main() {
  url := "https://edge-workers.laplace.cn/laplace/tts-cartesia"
  body := strings.NewReader(`{
    "text": "Hello, world!",
    "token": "string"
  }`)
  req, _ := http.NewRequest("POST", url, body)
  req.Header.Add("Content-Type", "application/json")
  res, _ := http.DefaultClient.Do(req)
  defer res.Body.Close()
  body, _ := ioutil.ReadAll(res.Body)

  fmt.Println(res)
  fmt.Println(string(body))
}
import requests

url = "https://edge-workers.laplace.cn/laplace/tts-cartesia"
body = {
  "text": "Hello, world!",
  "token": "string"
}
response = requests.request("POST", url, json = body, headers = {
  "Content-Type": "application/json"
})

print(response.text)
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
import java.net.http.HttpResponse.BodyHandlers;
import java.time.Duration;
import java.net.http.HttpRequest.BodyPublishers;

var body = BodyPublishers.ofString("""{
  "text": "Hello, world!",
  "token": "string"
}""");
HttpClient client = HttpClient.newBuilder()
  .connectTimeout(Duration.ofSeconds(10))
  .build();

HttpRequest.Builder requestBuilder = HttpRequest.newBuilder()
  .uri(URI.create("https://edge-workers.laplace.cn/laplace/tts-cartesia"))
  .header("Content-Type", "application/json")
  .POST(body)
  .build();

try {
  HttpResponse<String> response = client.send(requestBuilder.build(), BodyHandlers.ofString());
  System.out.println("Status code: " + response.statusCode());
  System.out.println("Response body: " + response.body());
} catch (Exception e) {
  e.printStackTrace();
}
using System;
using System.Net.Http;
using System.Text;

var body = new StringContent("""
{
  "text": "Hello, world!",
  "token": "string"
}
""", Encoding.UTF8, "application/json");

var client = new HttpClient();
var response = await client.PostAsync("https://edge-workers.laplace.cn/laplace/tts-cartesia", body);
var responseBody = await response.Content.ReadAsStringAsync();
null
{
  "success": false,
  "message": "string"
}
{
  "success": false,
  "message": "string"
}