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.
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
--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:
with_raw_response:
Request parameters
Unknown fields are ignored.
Output formats
TheContent-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
idor a fullnamefrom 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
voiceis omitted, the model’s default voice ("default": true) is used. A model with no default voice, such asvertex/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
alloyis spoken byJoanna.
Listing speech models
cURL
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 rateGET /v3/audio/speech/models shows. The amount charged for a request is in its x-edenai-cost header.
Limitations
- No
@edenairouting."model": "@edenai"returns400; name a model. - No
fallbacks. The field is ignored, like any unknown field: onlymodelis 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_responsewrites it to disk without holding it in memory, but does not start any sooner. - No
edenai_metadatablock. The body is raw audio, so the request metadata block is not returned, even withx-edenai-metadata: enabled; read thex-edenai-providerandx-edenai-costheaders 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