> ## Documentation Index
> Fetch the complete documentation index at: https://docs.chariot.in/llms.txt
> Use this file to discover all available pages before exploring further.

# Quickstart

> Generate your first speech audio with the Chariot API in a few minutes.

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

## Prerequisites

<Steps>
  <Step title="Create an API key">
    Sign in to the [Chariot dashboard](https://chariot.in) and generate an API key. Copy it somewhere safe, you send it on every request.
  </Step>

  <Step title="Pick a voice">
    List the available voices and copy a `voice_id`:

    ```bash theme={null}
    curl https://api.chariot.in/v1/voices \
      -H "chariotai-api-key: YOUR_API_KEY"
    ```
  </Step>
</Steps>

## Synthesize speech

Send text to [`POST /v1/tts`](/api-reference/endpoint/text-to-speech) and save the returned WAV:

<CodeGroup>
  ```bash cURL theme={null}
  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
  ```

  ```python Python theme={null}
  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"])
  ```

  ```javascript Node.js theme={null}
  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"));
  ```
</CodeGroup>

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`](/api-reference/endpoint/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 Python theme={null}
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
```

<Note>
  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.
</Note>

## Next steps

<CardGroup cols={2}>
  <Card title="Choose your API" icon="signs-post" href="/guides/text-to-speech/which-api">
    When to use REST, HTTP streaming, or WebSocket.
  </Card>

  <Card title="WebSocket streaming" icon="bolt" href="/guides/text-to-speech/websocket">
    Send text incrementally over a persistent connection.
  </Card>

  <Card title="Errors & status codes" icon="triangle-exclamation" href="/guides/resources/errors">
    Handle failures gracefully.
  </Card>

  <Card title="Credits & pricing" icon="coins" href="/guides/resources/credits">
    Understand what each request costs.
  </Card>
</CardGroup>
