Speech
Convert text to natural-sounding speech audio.
Convert text to natural-sounding speech audio. The endpoint mirrors OpenAI's
audio.speech.create so any OpenAI SDK works out of the box - just point
baseURL at https://api.aivene.com/v1.
POST /v1/audio/speechAuthentication
AuthorizationBearerrequiredAPI key as bearer token in the Authorization header. Create keys at
Manage API Keys.
Headers
Content-TypestringrequiredMust be application/json.
Body
inputstringrequiredThe text to convert to speech. Maximum length varies by model.
modelstringrequiredTTS model id from GET /v1/models.
voicestringrequiredVoice to use for synthesis. Available voices depend on the model.
instructionsstringoptionalAdditional instructions for voice style or tone. Supported by some models.
response_formatstringoptionalDefault mp3Audio output format.
mp3opusaacflacwavpcmspeednumberoptionalDefault 1.0Playback speed from 0.25 to 4.0.
Streaming audio
The response streams audio bytes directly. Set appropriate headers to handle binary data in your client.
Response
Content-TypestringoptionalMIME type matching the requested format (e.g. audio/mpeg for mp3).
bodybinaryoptionalRaw audio bytes in the requested format.
Example
curl https://api.aivene.com/v1/audio/speech \
-H "Authorization: Bearer $AIVENE_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "gemini-3.1-flash-tts",
"input": "Hello! Welcome to Aivene.",
"voice": "Kore"
}' \
--output speech.mp3Errors
All errors share one shape:
{ "error": { "message": "...", "type": "invalid_request_error" } }| Status | error.type | Meaning |
|---|---|---|
400 | validation_error | The body failed schema validation. The message names the offending field. |
400 | invalid_request_error | Unknown model, a model not available on this endpoint, or a voice or format the model does not support. |
401 | authentication_error | Missing or invalid API key. |
402 | invalid_request_error | Not enough credit for the request, an unpaid balance, or a spend limit was reached. |
403 | permission_denied_error | The account is suspended, an Admin key was used, or the model isn't included in your organization's tier. |
404 | not_found_error | The model is deprecated. The message names its replacement. |
408 | timeout_error | The model did not finish before the request timed out. |
429 | rate_limit_error | Your organization hit its rate limit for this model. Back off and retry. |
500 | internal_server_error | Unexpected server error. |
502 / 503 | upstream_error | The model is temporarily unavailable. Safe to retry. |
When the model itself rejects a request, the response keeps the model's
4xx status with type upstream_error or invalid_request_error, and
error.code names the cause when it is known (context_length_exceeded,
content_filter, request_too_large).