# Quickstart

Create a key, make a request, and stream the response.

## Get an API key

Create a key in the [console under API keys](https://platform.kenpathlabs.com/dashboard/keys). Keys look like `sk_live_…` and are shown once at creation; store them in a secret manager or environment variable, never in client code or version control.

```bash
export SVARA_API_KEY="sk_live_..."
```

## Make your first request

The `svara-voice` SDK is the shortest path. If you already use the OpenAI SDK, point it at the Svara base URL instead — the request shape is the same:

```bash
pip install git+https://github.com/kenpath-labs/svara-python.git
```

```python
from svara import Svara

client = Svara()                          # reads SVARA_API_KEY
audio = client.speech.create(
    input="नमस्ते! Welcome to Svara.",
    voice="sv_enhdbrj5",                  # Aanya
    response_format="mp3",
)
open("hello.mp3", "wb").write(audio)
```

```python
import os
from openai import OpenAI

client = OpenAI(
    base_url="https://api.kenpathlabs.com/v1",
    api_key=os.environ["SVARA_API_KEY"],
)

audio = client.audio.speech.create(
    model="svara-1",
    voice="sv_enhdbrj5",  # Aanya
    input="The quick brown fox jumps over the lazy dog.",
    response_format="mp3",
)
audio.write_to_file("out.mp3")
```

```javascript
import OpenAI from "openai";

const client = new OpenAI({
  baseURL: "https://api.kenpathlabs.com/v1",
  apiKey: process.env.SVARA_API_KEY,
});

const res = await client.audio.speech.create({
  model: "svara-1",
  voice: "sv_enhdbrj5", // Aanya
  input: "The quick brown fox jumps over the lazy dog.",
  response_format: "mp3",
});
await Bun.write("out.mp3", await res.arrayBuffer());
```

```bash
curl -X POST https://api.kenpathlabs.com/v1/audio/speech \
  -H "Authorization: Bearer $SVARA_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"voice": "sv_enhdbrj5",
       "input": "The quick brown fox jumps over the lazy dog.",
       "response_format": "mp3"}' \
  --output out.mp3   # voice sv_enhdbrj5 = Aanya
```

## Stream it

Set `stream: true` and consume chunks as they arrive; with `pcm` output the first bytes land in a few hundred milliseconds rather than after the whole clip is generated. If the text comes from an LLM, use the [WebSocket input-streaming API](https://docs.kenpathlabs.com/input-streaming.md) instead — it accepts text while the model is still writing, so synthesis doesn’t wait for a complete sentence:

```python
from svara import Svara

client = Svara()
for chunk in client.speech.stream(
    input="This sentence starts playing before it finishes generating.",
    voice="sv_enhdbrj5",            # Aanya
    response_format="pcm",          # 24 kHz, 16-bit LE, mono
):
    player.feed(chunk)              # your audio sink

# from an LLM? one WebSocket, speech before the sentence ends:
#   async for audio in AsyncSvara().speech.stream_input(deltas(), voice="sv_enhdbrj5"): ...
```

```python
with client.audio.speech.with_streaming_response.create(
    model="svara-1",
    voice="sv_enhdbrj5",  # Aanya
    input="This sentence starts playing before it finishes generating.",
    response_format="pcm",          # 24 kHz, 16-bit LE, mono
    extra_body={"stream": True},
) as response:
    for chunk in response.iter_bytes():
        player.feed(chunk)          # your audio sink
```

```bash
curl -N -X POST https://api.kenpathlabs.com/v1/audio/speech \
  -H "Authorization: Bearer $SVARA_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"voice": "sv_enhdbrj5", "stream": true, "response_format": "pcm",
       "input": "This sentence starts playing before it finishes generating."}' \
  | play -t raw -r 24000 -e signed -b 16 -c 1 -   # sox; voice sv_enhdbrj5 = Aanya
```

Format choices, playback, and telephony output are on the [Streaming](https://docs.kenpathlabs.com/streaming.md) page.

## Explore voices and languages

These endpoints are public, no key required:

- `GET /v1/voices`: the current voice roster, each with a `preview_url`
- `GET /v1/languages`: all 80 supported languages, for building pickers
- `GET /v1/models`: available models

> The [console playground](https://platform.kenpathlabs.com/dashboard/playground) runs the same API from the browser: try voices, languages, and multi-speaker scenes without writing code.
