Gemini 3.1 Flash TTS
Text-to-Speech • Google
google/gemini-3.1-flash-tts
- Third-party
- Zero data retention
| Model Info | |
|---|---|
| Zero data retention | Yes |
| Pricing | <ul><li>Input audio (per 1M tokens)$3.00</li><li>Input text (per 1M tokens)$0.75</li><li>Output audio (per 1M tokens)$12.00</li><li>Output text (per 1M tokens)$4.50</li></ul> |
Usage
const response = await env.AI.run(
'google/gemini-3.1-flash-tts',
{ text: 'Hello, welcome to Cloudflare AI Gateway!' },
)
console.log(response)
curl https://api.cloudflare.com/client/v4/accounts/$CLOUDFLARE_ACCOUNT_ID/ai/run \
--header "Authorization: Bearer $CLOUDFLARE_API_TOKEN" \
--header "Content-Type: application/json" \
--data '{
"model": "google/gemini-3.1-flash-tts",
"input": {
"text": "Hello, welcome to Cloudflare AI Gateway!"
}
}'
{
"audio": "data:audio/l16;base64,...",
"gatewayMetadata": {
"keySource": "Unified"
}
}
Examples
<details>
<summary>Custom Voice — Generate speech with a specific voice</summary>
const response = await env.AI.run(
'google/gemini-3.1-flash-tts',
{ text: 'The quick brown fox jumps over the lazy dog.', voice: 'Puck' },
)
console.log(response)
curl https://api.cloudflare.com/client/v4/accounts/$CLOUDFLARE_ACCOUNT_ID/ai/run \
--header "Authorization: Bearer $CLOUDFLARE_API_TOKEN" \
--header "Content-Type: application/json" \
--data '{
"model": "google/gemini-3.1-flash-tts",
"input": {
"text": "The quick brown fox jumps over the lazy dog.",
"voice": "Puck"
}
}'
{
"audio": "data:audio/l16;base64,...",
"gatewayMetadata": {
"keySource": "Unified"
}
}
</details>
<details>
<summary>Longer Text — Convert longer text to speech</summary>
const response = await env.AI.run(
'google/gemini-3.1-flash-tts',
{
text: 'Artificial intelligence has transformed the way we interact with technology. From voice assistants to autonomous vehicles, AI is reshaping our daily lives and creating new possibilities for innovation.',
voice: 'Charon',
},
)
console.log(response)
curl https://api.cloudflare.com/client/v4/accounts/$CLOUDFLARE_ACCOUNT_ID/ai/run \
--header "Authorization: Bearer $CLOUDFLARE_API_TOKEN" \
--header "Content-Type: application/json" \
--data '{
"model": "google/gemini-3.1-flash-tts",
"input": {
"text": "Artificial intelligence has transformed the way we interact with technology. From voice assistants to autonomous vehicles, AI is reshaping our daily lives and creating new possibilities for innovation.",
"voice": "Charon"
}
}'
{
"audio": "data:audio/l16;base64,...",
"gatewayMetadata": {
"keySource": "Unified"
}
}
</details>
<details>
<summary>Narrative Voice — Generate speech with a narrative voice style</summary>
const response = await env.AI.run(
'google/gemini-3.1-flash-tts',
{
text: 'Once upon a time, in a kingdom far away, there lived a brave knight who sought to protect the realm from all dangers.',
voice: 'Kore',
},
)
console.log(response)
curl https://api.cloudflare.com/client/v4/accounts/$CLOUDFLARE_ACCOUNT_ID/ai/run \
--header "Authorization: Bearer $CLOUDFLARE_API_TOKEN" \
--header "Content-Type: application/json" \
--data '{
"model": "google/gemini-3.1-flash-tts",
"input": {
"text": "Once upon a time, in a kingdom far away, there lived a brave knight who sought to protect the realm from all dangers.",
"voice": "Kore"
}
}'
{
"audio": "data:audio/l16;base64,...",
"gatewayMetadata": {
"keySource": "Unified"
}
}
</details>
Parameters
text
stringrequiredmaxLength: 10000The text to convert to speech. Maximum 10,000 characters.
voice
stringenum: 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, SulafatThe voice to use for speech synthesis
temperature
numberminimum: 0maximum: 2Controls randomness in generation (0-2)
topP
numberminimum: 0maximum: 1Nucleus sampling threshold (0-1). Tokens with cumulative probability up to topP are considered
topK
integerexclusiveMinimum: 0maximum: 9007199254740991Only sample from the top K tokens. Smaller K = more focused, larger K = more diverse
maxOutputTokens
integerexclusiveMinimum: 0maximum: 9007199254740991Maximum number of tokens to generate
▶stopSequences[]
arraySequences where the model will stop generating further tokens
audio
stringBase64-encoded audio data (WAV format)
API Schemas (Raw)
Was this helpful?
YesNo
On this page
{"@context":"https://schema.org","@type":"TechArticle","@id":"https://developers.cloudflare.com/ai/models/google/gemini-3.1-flash-tts/#page","headline":"Gemini 3.1 Flash TTS","url":"https://developers.cloudflare.com/ai/models/google/gemini-3.1-flash-tts/","inLanguage":"en","image":"https://developers.cloudflare.com/og-docs.png","publisher":{"@type":"Organization","name":"Cloudflare","description":"One platform for your apps, agents, and workforce. Build, secure, and scale without managing infrastructure","url":"https://www.cloudflare.com/","sameAs":["https://github.com/cloudflare","https://www.linkedin.com/company/cloudflare","https://x.com/cloudflare"],"logo":{"@type":"ImageObject","url":"https://developers.cloudflare.com/logo.svg"},"address":{"@type":"PostalAddress","streetAddress":"101 Townsend St","addressLocality":"San Francisco","addressRegion":"CA","postalCode":"94107","addressCountry":"US"},"contactPoint":[{"@type":"ContactPoint","contactType":"Customer Support","url":"https://support.cloudflare.com/","availableLanguage":["English"]},{"@type":"ContactPoint","contactType":"Sales","url":"https://www.cloudflare.com/contact/","availableLanguage":["English"]}]},"isPartOf":{"@type":"WebSite","@id":"https://developers.cloudflare.com/#website","name":"Cloudflare Docs","url":"https://developers.cloudflare.com/"}}
description: Google's most intelligent Gemini model with improved reasoning, a medium thinking level, and a 1M token context window. title: Gemini 3.1 Pro image: https://developers.cloudflare.com/og-docs.png
Documentation Index
Fetch the complete documentation index at: https://developers.cloudflare.com/llms.txt
Use this file to discover all available pages before exploring further.

