# Introduction

Text to speech over HTTP and WebSocket, in 80 languages, from one endpoint.

## Overview

The Svara API converts text to speech over HTTP and WebSocket. One model covers 80 languages and code-switches within a single request, with a library of 320 voices and eight output formats. Streamed, first audio typically arrives in a few hundred milliseconds.

- [POST /v1/audio/speech](https://docs.kenpathlabs.com/text-to-speech.md) synthesizes text you already have, buffered or streamed
- [WS /v1/audio/speech/stream-input](https://docs.kenpathlabs.com/input-streaming.md) takes text as it is produced — an LLM token stream, for example — and returns audio continuously
- `ulaw` and `alaw` at 8 kHz come out of the API directly, so telephony needs no transcoding step

## Base URL

```text
https://api.kenpathlabs.com/v1
```

## Compatibility

The API is request-compatible with the OpenAI and ElevenLabs speech APIs. If your code already calls either one, change the base URL and the key; no other edits are required.

- **OpenAI**: `POST /v1/audio/speech` — the primary endpoint, and the one that exposes every Svara parameter. The official OpenAI SDKs work unmodified.
- **ElevenLabs**: `POST /v1/text-to-speech/{voice_id}` and the related streaming, timestamp, and voices endpoints. The official ElevenLabs SDKs work unmodified, including their realtime WebSocket client.
- **Native WebSocket**: `/v1/audio/speech/stream-input` — Svara-specific, and the lowest-latency path for LLM-driven speech.

Per-SDK setup, including the `/v1` difference between the two base URL conventions, is on [SDKs & compatibility](https://docs.kenpathlabs.com/sdks.md).

## Your first call

```http
POST /v1/audio/speech
```

```python
# pip install git+https://github.com/kenpath-labs/svara-python.git
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)
```

```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": "नमस्ते! Welcome to Svara.",
    "response_format": "mp3"
  }' --output hello.mp3   # voice sv_enhdbrj5 = Aanya
```

```python
from openai import OpenAI

client = OpenAI(base_url="https://api.kenpathlabs.com/v1", api_key=SVARA_API_KEY)
audio = client.audio.speech.create(
    model="svara-1",
    voice="sv_enhdbrj5",  # Aanya
    input="नमस्ते! Welcome to Svara.",
    response_format="mp3",
)
audio.write_to_file("hello.mp3")
```

```javascript
import OpenAI from "openai";

const client = new OpenAI({ baseURL: "https://api.kenpathlabs.com/v1", apiKey: SVARA_API_KEY });
const res = await client.audio.speech.create({
  model: "svara-1",
  voice: "sv_enhdbrj5", // Aanya
  input: "नमस्ते! Welcome to Svara.",
  response_format: "mp3",
});
await Bun.write("hello.mp3", await res.arrayBuffer());
```

That mixed Hindi-English input is intentional: send raw text in any supported language, code-switching included, and the model handles it. No SSML, no phoneme markup.

## Next steps

- [Quickstart](https://docs.kenpathlabs.com/quickstart.md): key, first request, and streaming in five minutes
- [Text to speech](https://docs.kenpathlabs.com/text-to-speech.md): every request parameter explained
- [Input streaming](https://docs.kenpathlabs.com/input-streaming.md): wire an LLM’s output straight into speech
- [SDKs & compatibility](https://docs.kenpathlabs.com/sdks.md): using the OpenAI and ElevenLabs SDKs

> A machine-readable OpenAPI spec is served live at `https://api.kenpathlabs.com/openapi.json`: handy for generating typed clients.
