---
title: "Generate speech"
method: POST
path: "/audio/speech"
---

# Generate speech

`POST /audio/speech`

## Request

- Base URL: `https://www.ninjachat.ai/api/v1`
- URL: `https://www.ninjachat.ai/api/v1/audio/speech`
- Auth: HTTP bearer

## Headers

- `Idempotency-Key` string

## Request body

- SpeechRequest
  - `model` 'tts-1' | 'tts-1-hd', required
  - `input` string, required
  - `voice` 'alloy' | 'ash' | 'coral' | 'echo' | 'fable' | 'onyx' | 'nova' | 'sage' | 'shimmer', required
  - `response_format` 'mp3' | 'opus' | 'aac' | 'flac' | 'wav' | 'pcm'
  - `speed` number

## Response `200`

Binary audio. X-Request-ID and X-NinjaChat-Cost-USD identify the billed request. Buffered until successful generation so retries can safely replay.

## Other responses

- `400`: Invalid or unsupported request parameter.
- `401`: Missing or invalid API key.
- `402`: Insufficient balance or project spend limit reached.
- `429`: Rate limit exceeded.
- `500`: Gateway error.

---

[API](https://skmtc.dev/ninjachat/apis/ninjachat-api.md) · [All operations](https://skmtc.dev/ninjachat/apis/ninjachat-api/llms.txt) · [OpenAPI document](https://skmtc.dev/ninjachat/apis/ninjachat-api/revisions/fa7dfcbdcb03?raw)
