# Text-to-speech

`POST /v1/audio/speech` — Synthesize speech from text. Returns MP3 audio.

- Base URL: https://eroq.ai/v1
- Auth: `Authorization: Bearer eroq_sk_…` (create keys at https://eroq.ai/dashboard/keys)
- Credits: 3 per 100 characters

The response body is the MP3 itself (`audio/mpeg`) — pipe it straight to a file or an audio element. Input is capped at 5,000 characters per request.

Voices: `aria` (female), `orion` (male). Credits are charged per started block of 100 input characters — a 250-character line costs 9 credits.

## Request body

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `input` | string | yes | The text to speak. |
| `voice` | string | yes | `aria` or `orion`. |
| `model` | string | no | Only `eroq-voice-one` today. |

## Example request

```bash
curl https://eroq.ai/v1/audio/speech \
  -H "Authorization: Bearer $EROQ_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "model": "eroq-voice-one",
  "input": "That noise is the reactor missing its coolant flush. Again.",
  "voice": "aria"
}' \
  --output speech.mp3
```

```javascript
import { writeFile } from 'node:fs/promises'

const res = await fetch('https://eroq.ai/v1/audio/speech', {
  method: 'POST',
  headers: {
    Authorization: `Bearer ${process.env.EROQ_API_KEY}`,
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    "model": "eroq-voice-one",
    "input": "That noise is the reactor missing its coolant flush. Again.",
    "voice": "aria"
  }),
})
await writeFile('speech.mp3', Buffer.from(await res.arrayBuffer()))
```

```python
import os, requests

res = requests.post(
    "https://eroq.ai/v1/audio/speech",
    headers={"Authorization": f"Bearer {os.environ['EROQ_API_KEY']}"},
    json={
        "model": "eroq-voice-one",
        "input": "That noise is the reactor missing its coolant flush. Again.",
        "voice": "aria"
    },
)
open("speech.mp3", "wb").write(res.content)
```

```go
package main

import (
	"fmt"
	"io"
	"net/http"
	"os"
	"strings"
)

func main() {
	body := strings.NewReader(`{
  "model": "eroq-voice-one",
  "input": "That noise is the reactor missing its coolant flush. Again.",
  "voice": "aria"
}`)

	req, _ := http.NewRequest("POST", "https://eroq.ai/v1/audio/speech", body)
	req.Header.Set("Authorization", "Bearer "+os.Getenv("EROQ_API_KEY"))
	req.Header.Set("Content-Type", "application/json")

	res, _ := http.DefaultClient.Do(req)
	defer res.Body.Close()
	out, _ := os.Create("speech.mp3")
	defer out.Close()
	io.Copy(out, res.Body)
}
```

## Response

Content type: `audio/mpeg`
```json
(binary MP3 body — audio/mpeg)
```
---
Canonical: https://eroq.ai/docs/speech · Index for agents: https://eroq.ai/llms.txt · OpenAPI: https://eroq.ai/openapi.json
