The Gemini Flex API is an inference tier that offers a 50% cost reduction compared to standard rates, in exchange for variable latency and best-effort availability. It's designed for latency-tolerant workloads that require synchronous processing but don't need the real-time performance of the standard API.
How to use Flex
To use the Flex tier, specify the service_tier as flex in your request. By default, requests use the standard tier if this field is omitted.
Python
from google import genai
client = genai.Client()
interaction = client.interactions.create(
model="gemini-3.7-flash",
input="Analyze this dataset for trends...",
service_tier='flex'
)
print(interaction.output_text)
JavaScript
import { GoogleGenAI } from '@google/genai';
const client = new GoogleGenAI({});
async function main() {
const interaction = await client.interactions.create({
model: 'gemini-3.7-flash',
input: 'Analyze this dataset for trends...',
service_tier: 'flex'
});
console.log(interaction.output_text);
}
await main();
REST
curl -X POST "https://generativelanguage.googleapis.com/v1beta/interactions" \
-H "Content-Type: application/json" \
-H "x-goog-api-key: $GEMINI_API_KEY" \
-d '{
"model": "gemini-3.7-flash",
"input": "Analyze this dataset for trends...",
"service_tier": "flex"
}'
How Flex inference works
Gemini Flex inference bridges the gap between the standard API and the 24-hour turnaround of the Batch API. It utilizes off-peak, "sheddable" compute capacity to provide a cost-effective solution for background tasks and sequential workflows.
| Feature | Flex | Priority | Standard | Batch |
|---|---|---|---|---|
| Pricing | 50% discount | 75-100% more than Standard | Full price | 50% discount |
| Latency | Minutes (1–15 min target) | Low (Seconds) | Seconds to minutes | Up to 24 hours |
| Reliability | Best-effort (Sheddable) | High (Non-sheddable) | High / Medium-high | High (for throughput) |
| Interface | Synchronous | Synchronous | Synchronous | Asynchronous |
Key benefits
- Cost efficiency: Substantial savings for non-production evals, background agents, and data enrichment.
- Low friction: Simply add a single parameter to your existing requests.
- Synchronous workflows: Ideal for sequential API chains where the next request depends on the output of the previous one, making it more flexible than Batch for agentic workflows.
Use cases
- Offline evaluations: Running "LLM-as-a-judge" regression tests or leaderboards.
- Background agents: Sequential tasks like CRM updates, profile building, or content moderation where minutes of delay are acceptable.
- Budget-constrained research: Academic experiments that require high token volume on a limited budget.
Rate limits
Flex inference traffic counts towards your general rate limits; it doesn't offer extended rate limits like the Batch API.
Sheddable capacity
Flex traffic is treated with lower priority. If there is a spike in standard traffic, Flex requests may be preempted or evicted to ensure capacity for high-priority users. If you're looking for high-priority inference, check Priority inference
Error codes
When Flex capacity is unavailable or the system is congested, the API will return standard error codes:
- 503 Service Unavailable: The system is currently at capacity.
- 429 Too Many Requests: Rate limits or resource exhaustion.