Skip to main content
Generate speech from text through Eden AI’s OpenAI-compatible speech endpoint. Point any OpenAI client at https://api.edenai.run/v3 and client.audio.speech works as a drop-in replacement for OpenAI’s text to speech.

Overview

The response body is the audio file itself, as with OpenAI. Eden’s cost (USD) and provider come back in the x-edenai-cost and x-edenai-provider response headers.
Speech models are only available on /v3/audio/speech. They are not in GET /v3/models, which lists chat models.
This is different from Expert Model text to speech, which runs through /v3/universal-ai with each provider’s native options. Use /v3/audio/speech when you want an OpenAI-compatible, drop-in speech surface.

Models

Call GET /v3/audio/speech/models for the full list available in your region, with the per-character price of each model.
amazon/generative and amazon/long-form are in the model list, but no voice in GET /v3/audio/voices is available for them yet, so a request to either returns 400 when it names no voice or a voice from that list.

Generating speech

With --fail-with-body, an error makes curl exit with a non-zero status. The JSON error is still written to speech.mp3, so read that file to see why the request failed. The official OpenAI SDK works unchanged once base_url points at Eden AI:
To read the cost and provider headers from the SDK, use with_raw_response:

Request parameters

Unknown fields are ignored.

Output formats

The Content-Type of the response follows the response_format you request, not the audio the provider actually returns. Every provider returns mp3; the other formats depend on the provider: With vertex/chirp, set response_format to mp3 if you need MP3: when it is omitted, Google returns WAV under an audio/mpeg header.

Choosing a voice

GET /v3/audio/voices lists the voices the speech models accept. Each voice names the models that take it:
How the voice field of a speech request is matched:
  • An id or a full name from the list is matched without regard to case: "alloy" and "Alloy" are the same OpenAI voice. Provider ids are shorter and stable, so prefer them for voices with long display names, such as most ElevenLabs voices.
  • When voice is omitted, the model’s default voice ("default": true) is used. A model with no default voice, such as vertex/chirp, gets the first voice it accepts in alphabetical order, which may not speak the language of your text, so name a voice for it.
  • A voice of the model’s provider that the model does not accept returns 400, with the voices the model does accept in the error message.
  • Any other voice, including one that belongs to another provider, is sent to the provider unchanged. Cloned or account-specific voice ids still reach the provider this way. Amazon models read OpenAI’s voice names as Polly voices, so alloy is spoken by Joanna.

Listing speech models

cURL
Each entry carries its pricing, e.g. {"input_cost_per_character": 0.000015} for openai/tts-1. The endpoint takes the same view parameter as the other model listings.

Pricing

Speech is billed on the input text, per character (or per token for models priced that way), at the rate GET /v3/audio/speech/models shows. The amount charged for a request is in its x-edenai-cost header.

Limitations

  • No @edenai routing. "model": "@edenai" returns 400; name a model.
  • No fallbacks. The field is ignored, like any unknown field: only model is tried, and a failure is not retried on another model.
  • No streaming playback. The audio is returned once the provider has synthesized all of it. The SDK’s with_streaming_response writes it to disk without holding it in memory, but does not start any sooner.
  • No edenai_metadata block. The body is raw audio, so the request metadata block is not returned, even with x-edenai-metadata: enabled; read the x-edenai-provider and x-edenai-cost headers instead.

Next Steps

Speech to Text

Transcribe audio through the OpenAI-compatible transcriptions endpoint

Expert Text to Speech

Use each provider’s native voices and options through Universal AI