Audio speech (TTS)
Generate audio from text. OpenAI-compatible.
POST https://api.ecohash.com/v1/audio/speech
Headers
| Header | Value |
|---|---|
Authorization | Bearer eco_YOUR_KEY |
Content-Type | application/json |
Request body
| Field | Type | Required | Notes |
|---|---|---|---|
model | string | yes | TTS model ID (e.g. kokoro-82m) |
voice | string | yes | Voice identifier supported by the model |
input | string | yes | Text to synthesize, up to 4000 characters |
response_format | string | no | "mp3" (default), "wav", or "opus" |
speed | number | no | 0.5–2.0 playback speed multiplier |
stream | boolean | no | When 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.