# Getting Started with the Async Voice API

Welcome! This quick-start guide walks you through sending your first request and turning text into real-time audio.

## Prerequisites

- Developer account on [Async Voice API](https://async.com/developer/)
- API key
- A command-line HTTP client (examples use cURL; feel free to use Postman, Python requests, etc.)
- ffmpeg (optional, but handy for converting the raw stream to other formats for playback)

---

## Get Your API Key

1. Log in to the Async Voice API dashboard.
2. Navigate to API Keys → Create API Key.
3. Copy the key and store it securely (it starts with sk_).
4. You can export it as an environment variable so it never appears in your shell history:

```bash
export ASYNC_API_KEY="sk_xxxxxxxxxxxxxxxxx"
```



## Make Your First Request

Here’s a simple `curl` command that sends text and receives streamed audio in response:

```bash
curl -X POST https://api.async.com/text_to_speech/streaming \
  -H "Content-Type: application/json" \
  -H "x-Api-Key: your-api-key" \
  --data '{
    "model_id": "async_flash_v1.0",
    "transcript": "Welcome to Async, where imagination meets intelligent speech synthesis.",
    "voice": { "mode": "id", "id": "e0f39dc4-f691-4e78-bba5-5c636692cc04" },
    "output_format": {
      "container": "raw",
      "encoding": "pcm_s16le",
      "sample_rate": 44100
    }
  }' --output output.raw
```
> This example uses `async_flash_v1.0`. See [Models](https://docs.async.com/models-2161359m0) for all available models and their capabilities.

## Playing or Converting the Stream
The command above stores 44.1 kHz 16-bit mono PCM samples in speech.pcm.

Quick playback (macOS/Linux)
```bash
ffplay -f s16le -ar 44100 output.raw
```

Convert to WAV
```bash
ffmpeg -f s16le -ar 44100 -ac 1 -i output.raw output.wav
```
*Tip: For real-time playback, pipe the cURL output directly into ffplay:*
```bash
curl -L https://api.async.com/text_to_speech/streaming \
  -H "Content-Type: application/json" \
  -H "X-Api-Key: $ASYNC_API_KEY" \
  -d @request.json | ffplay -f s16le -ar 44100 -
```

## Handling Errors


| HTTP Code | Meaning |  Most common fixes |
| --- | --- | --- |
| 400 Bad Request | Validation error in your JSON. | Validate JSON, field names, and ranges. |
| 401 Unauthorized | Bad or missing X-Api-Key | Check key spelling; confirm it has TTS scope. |
| 429 Too Many Requests | You hit the rate limit. | Wait for the mentioned time and retry (or upgrade plan). |


Need help? [Ping us](https://async.com/sales) or hop into our developer [Discord](https://discord.com/invite/qEMhZxcJ3E). Happy building!


