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

# Speech-to-Text quickstart

> Transcribe your first audio file with Prisma v3.0 in a few minutes.

Send one short audio file to the REST endpoint and get its transcript back. Prisma v3.0 works out which Indian language or English is being spoken, so you do not need to know the language in advance.

You need an audio file of up to 30 seconds in WAV, MP3, OGG, FLAC, AAC or M4A. The examples call it `clip.wav`. If you do not have one, download a Hindi sample:

```bash theme={null}
curl -o clip.wav https://docs.gnani.ai/audio/samples/hi-IN.wav
```

There are clips for the other languages on [Sample audio](https://docs.gnani.ai/api/introduction/sample-audio.md).

**1. Create an API key**

Sign in to the [Gnani API dashboard](https://app.gnani.ai/voice) and generate an API key.

**2. Set your key**

The examples read your key from the `GNANI_API_KEY` environment variable, so it never appears in your code. Set it in the terminal you will run the examples from:

```bash macOS / Linux theme={null}
export GNANI_API_KEY="your-api-key"
```

```powershell Windows (PowerShell) theme={null}
$env:GNANI_API_KEY = "your-api-key"
```

```bash .env theme={null}
GNANI_API_KEY=your-api-key
```

If you use a `.env` file, load it with a library such as `python-dotenv` or `dotenv`, and keep the file out of version control.

**3. Install**

```bash Python theme={null}
pip install requests
```

```bash Node.js theme={null}
# Nothing to install. Node.js 18 or later includes fetch and FormData.
node --version
```

```bash Python SDK theme={null}
pip install gnani-vachana
```

cURL is preinstalled on macOS, Linux and Windows 10 or later.

**4. Run**

Save the code as a file and run it from the folder that contains `clip.wav`.

```bash cURL theme={null}
curl --request POST "https://api.vachana.ai/stt/v3" \
  --header "X-API-Key-ID: $GNANI_API_KEY" \
  --form audio_file=@clip.wav \
  --form model=prisma-v3.0 \
  --form language_code=indic-auto
```

```python Python theme={null}
# quickstart.py
import os
import requests

with open("clip.wav", "rb") as f:
    r = requests.post(
        "https://api.vachana.ai/stt/v3",
        headers={"X-API-Key-ID": os.environ["GNANI_API_KEY"]},
        files={"audio_file": ("clip.wav", f, "audio/wav")},
        data={"model": "prisma-v3.0", "language_code": "indic-auto"},
        timeout=60,
    )

print(r.status_code, r.json())
```

```javascript Node.js theme={null}
// quickstart.mjs
import { readFileSync } from "node:fs";

const form = new FormData();
form.append("audio_file", new Blob([readFileSync("clip.wav")], { type: "audio/wav" }), "clip.wav");
form.append("model", "prisma-v3.0");
form.append("language_code", "indic-auto");

const response = await fetch("https://api.vachana.ai/stt/v3", {
  method: "POST",
  headers: { "X-API-Key-ID": process.env.GNANI_API_KEY },
  body: form,
});

console.log(response.status, await response.json());
```

```python Python SDK theme={null}
# quickstart.py
from gnani.stt import GnaniSTTClient

client = GnaniSTTClient()  # reads GNANI_API_KEY

result = client.transcribe("clip.wav", model="prisma-v3.0", language_code="indic-auto")
print(result)
```

Run the Python examples with `python quickstart.py` and the Node.js example with `node quickstart.mjs`.

**5. Check the output**

A successful request returns `200` and a body like this:

```json theme={null}
{
  "success": true,
  "request_id": "5c1f0a52-6d62-4e0b-9a38-2f2b8a8f7a10",
  "transcript": "வணக்கம் எப்படி இருக்கீங்க",
  "model": "prisma-v3.0",
  "detected_language_code": "ta-IN",
  "processing_time": 0.58,
  "end_to_end_latency": 0.66
}
```

`transcript` is the text of what was said, and `detected_language_code` is the language it is in. Keep `request_id` if you need to contact support about this request.

## If it didn't work

| Status | Error | Fix |
| - | - | - |
| `401` | `MISSING_API_KEY` | `GNANI_API_KEY` is not set in this terminal. Set it again (step 2) in the same terminal you run the code from. |
| `401` | `INVALID_API_KEY` | The key is wrong or was revoked. Copy it again from the dashboard. |
| `403` | `SCOPE_NOT_ALLOWED` | Your key is not allowed to use Speech-to-Text. Use a key that has access to it. |
| `429` | `RATE_LIMITED` | Your account allows fewer requests at a time than you sent. Wait for the earlier request to finish, then retry. |
| `400` | `UNSUPPORTED_AUDIO_FORMAT` | The file extension is not supported. Convert the file to WAV or MP3. |
| `400` | `MAX_AUDIO_DURATION_EXCEEDED` | The audio is longer than 30 seconds. Trim it, or use [Batch transcription](https://docs.gnani.ai/api/STTBatch/Introduction.md) for long files. |
| `422` | `missing` (`audio_file` or `language_code`) | The file was not attached or `language_code` was left out. Check the file path and the form fields. |

Every error and its body is listed in the [Error Reference](https://docs.gnani.ai/api/introduction/errors.md).

## Next

> [card] [Prisma v3.0](https://docs.gnani.ai/api/STT/models/prisma-v3.md)
>
> Language detection, output styles and context hints.

> [card] [Realtime transcription](https://docs.gnani.ai/api/STT/stt-websocket.md)
>
> Stream live audio over a WebSocket and get text as people speak.

> [card] [Batch transcription](https://docs.gnani.ai/api/STTBatch/Introduction.md)
>
> Transcribe many files, or files longer than 30 seconds.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.