---
title: "Text to speech API · OpenAI-compatible, hosted in the EU"
description: "Generate natural speech from text with an OpenAI-compatible text to speech API. Open voice models for apps, IVR and accessibility, processed in the EU."
canonical: "https://inference.eu/api/audio-speech/"
language: "en"
---

POST /v1/audio/speech

# Text to speech API: OpenAI-compatible voices, processed in the EU

The speech endpoint turns text into spoken audio with open text to speech models. It uses the same request as OpenAI's \`/v1/audio/speech\`, so voice features built for that API, from read-aloud buttons to phone menus and voice agents, can switch to models running in European data centres by changing the base URL, key, model and voice.

[Contact sales](https://inference.eu/contact/)[Example request](#example)

1.  01API format: OpenAI
2.  02EU data centres
3.  03Covered by one DPA

POST /v1/audio/speech

```
curl https://api.inference.eu/v1/audio/speech \
  -H "Authorization: Bearer $INFERENCE_EU_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "kokoro-82m",
    "voice": "bf_emma",
    "input": "Your parcel has left our depot in Rotterdam and will arrive tomorrow between nine and twelve.",
    "response_format": "mp3",
    "speed": 1.0
  }' \
  --output delivery-update.mp3
```

## What the endpoint does

`POST /v1/audio/speech` takes a JSON body with the `model`, the `input` text and a `voice`, and returns the audio file itself as the response body rather than JSON. Save it straight to a file, as in the curl example with `--output`, or play it in your application. The response `Content-Type` header tells you the audio format.

Open voice models differ in the languages and voices they offer. Each model page lists its voices and languages, and the voice ids are specific to the model: an OpenAI voice name such as `alloy` will not exist on an open model, so pick one of the model's own voices.

## Key request fields

`input` is the text to speak. Write it the way it should sound: spell out abbreviations, units and unusual numbers if the model reads them oddly, and use punctuation to control pauses. Long texts should be split at sentence boundaries into several requests.

`response_format` sets the audio format: `mp3` is a good default for web and apps, `opus` is small and suited to streaming and telephony, `wav` and `pcm` are uncompressed for further processing, and `aac` and `flac` are also available on most models. `speed` changes the speaking rate, where 1.0 is normal. Models that support it accept `instructions` to steer tone and delivery.

## A practical pattern for voice features

A voice assistant chains three calls: speech to text for the user's question, chat completions for the answer, and text to speech for the reply. To keep it responsive, stream the chat response, split it into sentences as they arrive, and send each sentence to the speech endpoint while the next one is still being generated. Play the audio clips in order.

For fixed messages, such as phone menu prompts or onboarding audio, generate the files once and cache them rather than calling the API on every play. Store the model and voice used, so that later additions sound the same.

## Errors and edge cases

An unknown `voice` for the chosen model returns a 400 error that names the voice; check the model page or ask us for the list. Empty `input`, or text longer than the per-request limit, also returns 400. Because a successful response is binary audio, check the HTTP status before saving the body, otherwise you may write a JSON error into an mp3 file.

Pronunciation of names, brands and mixed-language text varies between models. Test with your real content, and if a word is consistently wrong, respell it phonetically in `input`. If people hear the audio, tell them it was generated by AI where the law or your own policy requires it.

## Text to speech

Endpoint

POST /v1/audio/speech

Category

Endpoints

API format

OpenAI

Base URL

api.inference.eu/v1

Processing

EU data centres

Training on your data

Never

## Text to speech: common questions

The questions buyers, developers and legal teams ask us most. Something missing? Ask us directly.

Yes. The path, JSON fields and binary response follow OpenAI's \`/v1/audio/speech\`, so \`client.audio.speech.create\` in the OpenAI SDKs works with the inference.eu base URL and key. Change \`model\` to an open voice model and \`voice\` to one of that model's voices.

No. Voice names are defined by each model, and OpenAI's voices belong to OpenAI's models. Choose a voice from the open model you call; each model page lists them. Pick a voice per language and use case, and keep it in configuration so you can change it later.

That depends on the model. Some open voice models focus on English and a handful of other languages, while others cover more European languages. Check the model page for the languages each one supports, and test pronunciation with real sentences from your product before you choose.

Set \`response\_format\` to \`mp3\`, \`opus\`, \`aac\`, \`flac\`, \`wav\` or \`pcm\`, depending on what the model supports. \`mp3\` suits most apps, \`opus\` is efficient for streaming and voice calls, and \`wav\` or \`pcm\` are best when you want to process the audio further.

Do not wait for a complete chat answer. Stream the text from the chat model, cut it into sentences, and send each sentence to the speech endpoint as soon as it is complete. The first sentence plays while later ones are generated, which makes a voice assistant feel far more responsive.

Each request has a maximum input length that depends on the model and your plan, and we confirm it with you. For long articles or documents, split the text at sentence or paragraph boundaries, generate each part and join the audio files in order.

The rights depend on the licence of the voice model, which is listed on each model page. Most open voice models allow commercial use, but check the licence and any rules about imitating real people. Where your users hear AI-generated speech, disclose it as the law or your policy requires.

No. The text is processed in EU data centres to produce the audio and is not used to train models. The audio is returned to you in the response; storing and distributing it is up to you.

[Ask a question](https://inference.eu/contact/)

## Related

[API overview](https://inference.eu/api/)

-   [Speech to textTranscribe audio with Whisper through an OpenAI-compatible speech to text API. Meetings, calls and voice notes, processed in EU data centres.Endpoints](https://inference.eu/api/audio-transcriptions/)
-   [Chat completionsSend chat messages to open-weight models with the OpenAI chat completions format. Requests are processed in EU data centres and never used for training.Endpoints](https://inference.eu/api/chat-completions/)
-   [StreamingStream tokens from open models as they are generated, with OpenAI and Anthropic server-sent events. Examples, chunk format and error handling.Guides](https://inference.eu/api/streaming/)

## Move your AI workloads to EU infrastructure

Tell us which models you use and roughly how much traffic you have. We reply within one working day with pricing and next steps.

-   Reply within one working day
-   Pricing for your volume
-   DPA ready to sign
