Audio Series
Gemini 3.8 Flash TTS: API Reference
- Google's Gemini text-to-speech model: send text, get spoken audio back. One speaker per request, with 30 prebuilt voices.
- Gemini native format:
POST https://api.apiko.app/v1/models/gemini-3.8-flash-tts:generateContent. Only/v1is served; the same path under/v1betareturns 404. - Google GenAI SDKs work unchanged: set the base URL to
https://api.apiko.appand the API version tov1. - Billed per token: text input tokens, plus audio output tokens at 25 tokens per second of speech. Live prices are on the model page.
POST
Authorizations
Send
Authorization: Bearer <API_KEY>. Create keys in Console → API Keys.x-goog-api-key
string
Alternative to
Authorization: x-goog-api-key: <API_KEY>, the header Google GenAI SDKs send.Body
application/json
contents
object[]required
The text to read, as one user turn:
[{"role": "user", "parts": [{"text": "…"}]}]. The text is read as written. Text input only; audio, images and files are not accepted. The website playground takes up to 1,000 characters per request.generationConfig.responseModalities
string[]required
Must be
["AUDIO"].Example:
["AUDIO"]generationConfig.speechConfig.voiceConfig.prebuiltVoiceConfig.voiceName
enum<string>required
One of the 30 prebuilt voices. Names are case-sensitive.
Available options:
Zephyr, Puck, Charon, Kore, Fenrir, Leda, Orus, Aoede, Callirrhoe, Autonoe, Enceladus, Iapetus, Umbriel, Algieba, Despina, Erinome, Algenib, Rasalgethi, Laomedeia, Achernar, Alnilam, Schedar, Gacrux, Pulcherrima, Achird, Zubenelgenubi, Vindemiatrix, Sadachbia, Sadaltager, SulafatExample:
"Kore"multiSpeakerVoiceConfig
not supported
Multi-speaker audio is not available through APIKO: send one
voiceConfig per request. Per-part speaker or style metadata is dropped by the gateway, and streaming has not been verified on this route, so use the non-streaming generateContent call shown here.Response
200 - application/json
candidates[0].content.parts[].inlineData
object
The audio, base64-encoded in
data. Check mimeType: depending on the upstream route it is one of two formats.audio/wav:datais already a complete WAV file. Decode and save it as is.audio/L16;codec=pcm;rate=24000oraudio/l16; rate=24000; channels=1: raw 16-bit little-endian mono PCM at 24 kHz with no header. Prepend a 44-byte WAV header (or wrap it with any audio library) before playing it.- When several parts carry audio, join their samples in order under one header. Every example on this page handles both formats and writes
speech.wav.
usageMetadata
object
Billed tokens:
promptTokenCount for the text you sent, candidatesTokenCount for the generated audio (about 25 tokens per second of speech).Errors
Errors use the OpenAI error shape <code>{"error": {"message", "type", "code"}}</code>.
400
invalid_request_error
The request is malformed. Fix it; do not retry it unchanged.
401
authentication_error
The API key is missing, invalid or revoked.
403
insufficient_user_quota
The balance cannot cover the request. Top up in Console → Billing.
404
not found
Wrong path: the speech route is only served under
/v1, not /v1beta.model_not_found: the model id is wrong or the model was retired. Check it with GET /v1/models; do not retry.429
rate_limit_error
Too many requests. Retry with exponential backoff.
503
model_not_found
The model exists but none of its routes can take the request right now. Retry later with exponential backoff.