---
title: "Generate speech audio from text"
method: POST
path: "/audio/speech"
tags: ["Audio"]
---

# Generate speech audio from text

`POST /audio/speech`

Generates audio from the provided text using the OpenAI-compatible
Audio API. Mirrors the OpenAI `POST /v1/audio/speech` request body.
The response is the synthesized audio as raw binary bytes; the actual
`Content-Type` header of the response reflects the requested
`response_format` (e.g. `audio/mpeg` for `mp3`).

Not every provider implements the Audio API. Requests routed to a
provider that does not support it return `400 Bad Request` with an
explanatory error message; use `/chat/completions` for those providers.

## Query parameters

- `provider` 'ollama' | 'ollama_cloud' | 'groq' | 'llamacpp' | 'openai' | 'cloudflare' | 'cohere' | 'anthropic' | 'deepseek' | 'google' | 'mistral' | 'minimax' | 'moonshot' | 'nvidia' | 'zai'

## Request body

- CreateSpeechRequest — Request body for generating speech audio via the OpenAI-compatible Audio API.
  - `model` string, required — Model ID to use for speech synthesis (e.g. `gpt-4o-mini-tts` or `tts-1`).
  - `input` string, required — The text to synthesize into audio (4096 characters maximum).
  - `instructions` string — Control the voice of your generated audio with additional instructions. Does not work with `tts-1` or `tts-1-hd`.
  - `voice` string, required — The voice to use when generating the audio. OpenAI built-in voices are `alloy`, `ash`, `ballad`, `coral`, `echo`, `fable`, `onyx`, `nova`, `sage`, `shimmer`, `verse`, `marin`, and `cedar`. Other providers accept their own voice identifiers.
  - `response_format` 'mp3' | 'opus' | 'aac' | 'flac' | 'wav' | 'pcm' — The audio format of the response.
  - `speed` number — The speed of the generated audio.
  - `language` string — ISO 639-1 code for the language of the generated speech. Non-standard extension: OpenAI's speech API has no language field (the name matches its transcription API). Forwarded to the provider as-is; the gateway's built-in local engine (`local/qwen3-tts`) supports `zh`, `en`, `de`, `it`, `pt`, `es`, `ja`, `ko`, `fr` and `ru`, and rejects other codes.
  - `reference_audio` string, byte — Base64-encoded audio sample for zero-shot voice cloning. The generated speech mimics the voice in the sample. Best results with a clean mono recording between 1 and 30 seconds; WAV is the safest container. Forwarded to the provider as-is - only providers with voice-cloning support honor it (e.g. Qwen3-TTS-compatible backends); others ignore or reject it. Not supported by OpenAI.

## Response `200`

The synthesized audio as raw binary bytes. The actual `Content-Type`
header of the response reflects the requested `response_format`.

## Other responses

- `400` — The selected provider does not implement the Audio API. The gateway returns this when a request is routed to a provider without speech synthesis support.
- `401` — Unauthorized
- `500` — Internal server error

## Changes

- **2026-09-01** `3372460393eb` — 1 info
  - added the new optional request property `language`
- **2026-08-31** `4419fdfdc00e` — 1 info
  - endpoint added

[Change history](https://skmtc.dev/inference-gateway/apis/inference-gateway-api/changes/audio/speech/post.md)

---

[API](https://skmtc.dev/inference-gateway/apis/inference-gateway-api.md) · [All operations](https://skmtc.dev/inference-gateway/apis/inference-gateway-api/llms.txt) · [OpenAPI document](https://skmtc-service-production.skmtc.workers.dev/v1/apis/inference-gateway/inference-gateway-api/revisions/1830d52f7717/schema)
