Skip to content
HomeModels
DocsAudio & speech

Gemini native audio

Generate speech in the native Gemini format. Configure audio output and voice with generationConfig.

Google Gemini compatible
POST/v1beta/models/{model}:generateContent
Base URLhttps://api.linkinfra.ai

Authorization

Bearer Token
AuthorizationBearer <token>

Authenticate requests with your API key in the request header:

Authorization: Bearer sk-your-api-key

Need a key? Create one in the console

Choose a speech-capable model, such as gemini-2.5-flash-preview-tts. inlineData.data contains Base64 audio. Decode according to mimeType; raw PCM cannot be played as an MP3 file.

modelstringrequired

Gemini model ID without the models/ prefix.

Request body

application/json
contentsarray<object>required

Conversation content in the native Gemini format.

Show child properties2
rolestring

Content role: user or model.

partsarray<object>required

Text, image, or audio content parts.

Show child properties2
textstring

Text content.

inlineDataobject

Inline media with mimeType and Base64-encoded data.

generationConfigobjectrequired

Speech generation settings.

Show child properties2
responseModalitiesarray<string>required

Use ["AUDIO"] to request audio output.

speechConfigobjectrequired

Voice settings.

Show child properties1
voiceConfigobjectrequired

Set prebuiltVoiceConfig.voiceName, for example Kore.

Response

application/json
200Successful response
candidatesarray<object>

Generated candidates. Content is in content.parts.

usageMetadataobject

Input, output, and total token usage.

Request failed? Read the error handling guide