Skip to main content
This guide takes you from an API key to synthesized audio, then to a low-latency stream.

Prerequisites

1

Create an API key

Sign in to the Chariot dashboard and generate an API key. Copy it somewhere safe, you send it on every request.
2

Pick a voice

List the available voices and copy a voice_id:
curl https://api.chariot.in/v1/voices \
  -H "chariotai-api-key: YOUR_API_KEY"

Synthesize speech

Send text to POST /v1/tts and save the returned WAV:
curl -X POST https://api.chariot.in/v1/tts \
  -H "chariotai-api-key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "voice_id": "bac7d666-094d-4698-91fa-741d60fce662",
    "text": "Hello from Chariot."
  }' \
  --output speech.wav
import requests

resp = requests.post(
    "https://api.chariot.in/v1/tts",
    headers={"chariotai-api-key": "YOUR_API_KEY"},
    json={
        "voice_id": "bac7d666-094d-4698-91fa-741d60fce662",
        "text": "Hello from Chariot.",
    },
)
resp.raise_for_status()

with open("speech.wav", "wb") as f:
    f.write(resp.content)

print("Inference:", resp.headers["Inference-Id"])
print("Credits charged:", resp.headers["Credit-Utilized"])
import { writeFile } from "node:fs/promises";

const resp = await fetch("https://api.chariot.in/v1/tts", {
  method: "POST",
  headers: {
    "chariotai-api-key": "YOUR_API_KEY",
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    voice_id: "bac7d666-094d-4698-91fa-741d60fce662",
    text: "Hello from Chariot.",
  }),
});

if (!resp.ok) throw new Error(await resp.text());

const audio = Buffer.from(await resp.arrayBuffer());
await writeFile("speech.wav", audio);
console.log("Credits charged:", resp.headers.get("Credit-Utilized"));
The audio comes back as the response body. The Credit-Utilized header reports the cost (1 credit per character).

Stream for low latency

For real-time playback, use POST /v1/tts/stream. It returns raw 16-bit PCM at 44.1 kHz as it is generated, so you can start playing before synthesis finishes:
Python
import requests

with requests.post(
    "https://api.chariot.in/v1/tts/stream",
    headers={"chariotai-api-key": "YOUR_API_KEY"},
    json={
        "voice_id": "bac7d666-094d-4698-91fa-741d60fce662",
        "text": "This audio streams back as it is generated.",
    },
    stream=True,
) as resp:
    resp.raise_for_status()
    for chunk in resp.iter_content(chunk_size=4096):
        # Feed each PCM chunk straight into your audio player.
        play(chunk)  # replace with your playback sink
The stream is headerless PCM (audio/L16, 44100 Hz, mono, signed 16-bit little-endian), not a WAV file. Your player must be configured for that format, or you must prepend a WAV header yourself. The fully assembled WAV is also available at the X-audio-url header once the stream completes.

Next steps

Choose your API

When to use REST, HTTP streaming, or WebSocket.

WebSocket streaming

Send text incrementally over a persistent connection.

Errors & status codes

Handle failures gracefully.

Credits & pricing

Understand what each request costs.