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

# Quickstart

> Make your first request to the SomyaLabs API.

<Note>
  Base URL: `https://api.somya.ai`. Replace `YOUR_API_KEY` with a real key — see
  [Authentication](/authentication).
</Note>

## 1. Get an API key

Sign in to the [Playground](https://playground.somya.ai), open **API keys**, and
create one. Copy the `key` value — it's returned only once.

## 2. Synthesize speech (TTS)

Send text to `POST /v1/speech/synthesize`. The response streams as
**newline-delimited JSON** (`application/x-ndjson`) — one record per audio chunk —
so you can begin playback before synthesis finishes.

<CodeGroup>
  ```bash cURL theme={null}
  curl -N -X POST https://api.somya.ai/v1/speech/synthesize \
    -H "X-API-Key: YOUR_API_KEY" \
    -H "Content-Type: application/json" \
    -d '{ "text": "Namaste! Aapka swaagat hai." }'
  ```

  ```python Python theme={null}
  import requests

  resp = requests.post(
      "https://api.somya.ai/v1/speech/synthesize",
      headers={"X-API-Key": "YOUR_API_KEY"},
      json={"text": "Namaste! Aapka swaagat hai."},
      stream=True,
  )
  for line in resp.iter_lines():
      if line:
          print(line)  # one JSON record per audio chunk (see below)
  ```

  ```typescript TypeScript theme={null}
  const resp = await fetch("https://api.somya.ai/v1/speech/synthesize", {
    method: "POST",
    headers: { "X-API-Key": "YOUR_API_KEY", "Content-Type": "application/json" },
    body: JSON.stringify({ text: "Namaste! Aapka swaagat hai." }),
  });

  const reader = resp.body!.getReader();
  const decoder = new TextDecoder();
  let buffer = "";
  while (true) {
    const { done, value } = await reader.read();
    if (done) break;
    buffer += decoder.decode(value, { stream: true });
    const lines = buffer.split("\n");
    buffer = lines.pop() ?? ""; // keep the trailing partial line
    for (const line of lines) {
      if (line.trim()) console.log(JSON.parse(line)); // { chunk_b64, is_final }
    }
  }
  ```
</CodeGroup>

<Note>
  `text` is required (1–2500 characters). `voice` and `ref_audio` are optional —
  omitting `voice` uses the default. To pick a specific voice (and its language),
  pass a voice **slug** from `GET /v1/voices`. See
  [Text to Speech](/models/tts) for the streaming format and voice details.
</Note>

### Authentication header

You can authenticate with **either** header — they're equivalent:

```bash theme={null}
X-API-Key: YOUR_API_KEY
# or
Authorization: Bearer YOUR_API_KEY
```

Prefer `X-API-Key` for server-to-server calls with a SomyaLabs API key.

## 3. Transcribe audio (ASR)

Send an audio file to `POST /v1/speech/transcriptions` as
`multipart/form-data` under the `audio` field:

```bash cURL theme={null}
curl -X POST https://api.somya.ai/v1/speech/transcriptions \
  -H "X-API-Key: YOUR_API_KEY" \
  -F "audio=@recording.wav"
```

The response uses the standard envelope, with the transcript under `data.text`:

```json theme={null}
{ "success": true, "data": { "text": "namaste aapka swaagat hai" } }
```

See [Speech to Text](/models/asr) for formats and limits.

## Next steps

<CardGroup cols={2}>
  <Card title="API Reference" icon="code" href="/api-reference/introduction">
    Every endpoint, generated live from the OpenAPI spec.
  </Card>

  <Card title="Errors" icon="triangle-exclamation" href="/guides/errors">
    Error envelope, codes, and how to handle non-200 responses.
  </Card>
</CardGroup>
