Skip to main content

Audio speech (TTS)

Generate audio from text. OpenAI-compatible.

POST https://api.ecohash.com/v1/audio/speech

Headers

HeaderValue
AuthorizationBearer eco_YOUR_KEY
Content-Typeapplication/json

Request body

FieldTypeRequiredNotes
modelstringyesTTS model ID (e.g. kokoro-82m)
voicestringyesVoice identifier supported by the model
inputstringyesText to synthesize, up to 4000 characters
response_formatstringno"mp3" (default), "wav", or "opus"
speednumberno0.5–2.0 playback speed multiplier
streambooleannoWhen true, audio bytes are streamed as they are generated instead of buffered until the end — lower time-to-first-audio for long inputs

Example request

curl https://api.ecohash.com/v1/audio/speech \
-H "Authorization: Bearer eco_YOUR_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "kokoro-82m",
"voice": "af_bella",
"input": "Hello from EcoLink."
}' \
--output hello.mp3

Response

The response body is the audio bytes directly, with Content-Type matching the requested format (audio/mpeg, audio/wav, or audio/ogg). Pipe directly to a file.

Streaming

Set "stream": true to receive the audio as a stream instead of a single buffered response. The bytes begin arriving as soon as the model starts producing them, which lowers time-to-first-audio for longer text. Write the chunks to a file or feed them to an audio player as they arrive:

curl https://api.ecohash.com/v1/audio/speech \
-H "Authorization: Bearer eco_YOUR_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "kokoro-82m",
"voice": "af_bella",
"input": "This response is streamed as it is generated.",
"stream": true
}' \
--output stream.mp3

Errors

See Errors. Common: 401, 402, 404, 429.