Skip to article
API429 / Field notes

Gemini Batch API, Flex, and Priority Inference: Capacity Planning for AI Workloads

Compare Google Gemini Priority, Standard, Flex, and Batch inference tiers, forecast launch quota across RPM and TPM, and isolate asynchronous queues from live traffic.

Hourglass and a queue of paper request cards
Editorial photo illustration: Hourglass and a queue of paper request cards. Topic: Gemini Batch API, Flex, and Priority Inference: Capacity Planning for AI Workloads.

Routing urgent customer interactions, background sequential agents, and million-row offline evaluations through a single synchronous execution path is one of the fastest ways to trigger HTTP 429 outages. Google's direct Gemini API provides four distinct execution tiers—Priority, Standard, Flex, and Batch API—each with its own latency target, pricing multiplier, failure behavior, and quota rules.

This guide consolidates Gemini Batch API, Flex inference, Priority inference, and pre-launch quota forecasting into one capacity-planning reference. Use it alongside Gemini API rate limits and queue design and the Google provider hub.

Compare Priority, Standard, Flex, and Batch inference tiers

In Google's direct Priority inference, Flex inference, and Batch API documentation, the four execution tiers serve fundamentally different operational contracts. When using direct Google endpoints or OpenAI-compatible SDKs against Google's compatibility layer, service_tier selects between synchronous tiers while Batch API uses asynchronous job submission.

Execution tier Direct Google pricing vs Standard Target latency & interface Rate-limit & quota accounting Congestion / overflow behavior
Priority (service_tier="priority") 75–100% premium over Standard (billed at Standard if downgraded) Seconds; synchronous (generateContent, Interactions, or OpenAI compatibility) Holds its own limit (0.3x standard model/tier limit by default) while counting toward overall interactive rate limits Graceful server-side downgrade to standard processing; inspect x-gemini-service-tier response header
Standard Full standard price Seconds to minutes; synchronous Project-level RPM, input_TPM, RPD, and applicable spend windows Returns 429 RESOURCE_EXHAUSTED or 503 when project or service limits saturate
Flex (service_tier="flex") 50% discount vs Standard 1–15 minutes target; synchronous (increase client timeout to >= 10 minutes) Counts toward general project rate limits; does not grant extended Batch quotas Sheddable off-peak compute; returns 429 or 503 when preempted—never auto-upgrades to Standard
Batch API 50% discount vs Standard Up to 24-hour turnaround; asynchronous file/job submission Dedicated batch_enqueued_tokens and separate batch limits Queued asynchronously until completion; poll job state or consume webhook callback

Important boundary: do not assume an external OpenAI-compatible gateway forwards vendor-specific service_tier parameters or exposes direct Google Batch endpoints unless documented in the gateway's public OpenAPI contract and customer documentation. Always check published rates on /en/pricing and model availability on /en/models.

Why Flex and Priority failure modes require opposite client rules

Teams frequently misconfigure retry and timeout policies because they treat Priority and Flex as simple price toggles:

  • Priority inference requires downgrade telemetry, not blind re-sends: Because direct Google Priority defaults to 0.3x of your standard model/tier rate limit, marking every request priority quickly saturates the Priority cap. When Google gracefully downgrades overflow traffic to Standard processing, the call succeeds and charges the Standard rate. Monitor the x-gemini-service-tier response header to verify whether your critical workload actually ran on priority or standard.
  • Flex inference requires 10+ minute client timeouts and strict isolation: Flex uses sheddable capacity and targets 1 to 15 minutes of latency. If your HTTP client uses a 30-second timeout, it will disconnect mid-flight, waste tokens, and trigger duplicate retries. Furthermore, because Flex counts against your general interactive rate limits and never auto-upgrades to Standard (to prevent unexpected full-price billing), aggressive Flex workers can starve your live Standard traffic.

Forecast launch quota across RPM, input TPM, and retry reserves

Average daily traffic projections hide launch-day 429 risk. Whether launching an interactive assistant in Cursor or Claude Code, or scheduling an enrichment pipeline in n8n, calculate peak-minute demand across every active dimension before rollout:

  1. Peak interactive RPM: Multiply peak concurrent active users by requests per minute per user, then multiply by your burst factor (1.5x - 2.5x) and retry budget allowance (for example, 1.20x from your retry budget policy).
  2. Peak input_TPM: Multiply peak RPM by p95 prompt + history + tool-schema tokens. Long-context prompts often saturate input_TPM while RPM is below 20% of capacity.
  3. Priority tier cap check: If routing critical calls to direct Google Priority inference, verify that peak critical demand stays within 0.30 * standard_limit so critical traffic does not constantly downgrade.
  4. Asynchronous Batch separation: Move any workload that can tolerate multi-hour turnaround (nightly evals, catalog backfills, bulk classification) out of synchronous Flex/Standard queues and into asynchronous batch execution.

Runnable offline Python tier router and launch quota forecaster

The following self-contained Python 3.10+ script evaluates workload routing across Priority, Standard, Flex, and Batch tiers and computes whether a launch forecast fits within project RPM, input_TPM, and Priority (0.3x) thresholds:

from __future__ import annotations
from dataclasses import dataclass


@dataclass(frozen=True)
class TierRoutingPlan:
    selected_tier: str
    client_timeout_s: int
    counts_toward_interactive_rpm: bool
    notes: str


@dataclass(frozen=True)
class QuotaForecastResult:
    fits_standard_rpm: bool
    fits_input_tpm: bool
    fits_priority_cap: bool
    required_rpm: float
    required_input_tpm: float
    required_priority_rpm: float
    priority_rpm_cap: float


def select_execution_tier(
    *,
    is_user_blocking: bool,
    business_critical: bool,
    can_wait_hours: bool,
    sequential_chain: bool,
) -> TierRoutingPlan:
    if can_wait_hours and not is_user_blocking and not sequential_chain:
        return TierRoutingPlan(
            selected_tier="batch",
            client_timeout_s=60,
            counts_toward_interactive_rpm=False,
            notes="Submit asynchronously; isolate from live RPM/TPM.",
        )
    if is_user_blocking and business_critical:
        return TierRoutingPlan(
            selected_tier="priority",
            client_timeout_s=30,
            counts_toward_interactive_rpm=True,
            notes="Inspect x-gemini-service-tier header for graceful downgrade to standard.",
        )
    if not is_user_blocking and sequential_chain:
        return TierRoutingPlan(
            selected_tier="flex",
            client_timeout_s=600,
            counts_toward_interactive_rpm=True,
            notes="Use >=10 min timeout; sheddable capacity counts toward general rate limits.",
        )
    return TierRoutingPlan(
        selected_tier="standard",
        client_timeout_s=60,
        counts_toward_interactive_rpm=True,
        notes="Default synchronous path guarded by local queue admission.",
    )


def forecast_launch_capacity(
    *,
    peak_standard_rpm: float,
    peak_priority_rpm: float,
    peak_flex_rpm: float,
    p95_input_tokens: int,
    burst_multiplier: float,
    retry_budget_multiplier: float,
    project_rpm_limit: float,
    project_input_tpm_limit: float,
) -> QuotaForecastResult:
    total_Factor = burst_multiplier * retry_budget_multiplier
    interactive_rpm = (peak_standard_rpm + peak_priority_rpm + peak_flex_rpm) * total_Factor
    priority_rpm = peak_priority_rpm * total_Factor
    input_tpm = interactive_rpm * p95_input_tokens
    priority_cap = round(project_rpm_limit * 0.30, 2)

    return QuotaForecastResult(
        fits_standard_rpm=interactive_rpm <= project_rpm_limit,
        fits_input_tpm=input_tpm <= project_input_tpm_limit,
        fits_priority_cap=priority_rpm <= priority_cap,
        required_rpm=round(interactive_rpm, 2),
        required_input_tpm=round(input_tpm, 2),
        required_priority_rpm=round(priority_rpm, 2),
        priority_rpm_cap=priority_cap,
    )


if __name__ == "__main__":
    tier_plan = select_execution_tier(
        is_user_blocking=False,
        business_critical=False,
        can_wait_hours=False,
        sequential_chain=True,
    )
    forecast = forecast_launch_capacity(
        peak_standard_rpm=180.0,
        peak_priority_rpm=45.0,
        peak_flex_rpm=40.0,
        p95_input_tokens=3200,
        burst_multiplier=1.4,
        retry_budget_multiplier=1.15,
        project_rpm_limit=500.0,
        project_input_tpm_limit=1500000.0,
    )
    print("Tier routing plan:", tier_plan)
    print("Launch capacity forecast:", forecast)

Before launch, combine this capacity math with adaptive throttling and ramp-up controls, credential-scoped catalog checks, and scoped workload health observations. Check the FAQ for account funding and token rules.

FAQ

Does Gemini Flex inference have separate rate limits like the Batch API?

No. Google documents that Flex inference counts toward your project's general interactive rate limits rather than granting separate extended quotas like the Batch API. Always cap Flex concurrency so background chains cannot exhaust live user RPM or TPM.

What happens when traffic exceeds Gemini Priority inference rate limits?

By default, direct Google Priority inference holds a rate limit of 0.3x the standard model/tier limit. When Priority capacity is exceeded due to congestion, Google gracefully downgrades overflow requests to Standard processing and bills them at the Standard rate. Clients should inspect the x-gemini-service-tier response header to track downgrade frequency.

Why does Google recommend a 10-minute timeout for Flex inference?

Flex inference targets a 1-to-15-minute turnaround using sheddable off-peak compute and may sit in a server queue before execution. Short client timeouts close the socket prematurely, causing uncertain outcomes and wasted retries.

Does Flex inference automatically upgrade to Standard if off-peak capacity is full?

No. To prevent unexpected full-price charges, Google does not automatically upgrade a Flex request to the Standard tier when Flex capacity is unavailable; instead, the API returns 503 Service Unavailable or 429 Too Many Requests.

Sources & further reading

  1. Google Gemini API Priority inference guide
  2. Google Gemini API Flex inference guide
  3. Google Gemini Batch API documentation
  4. Google Gemini API OpenAI compatibility guide
  5. Google Gemini API rate limits
  6. API429 customer documentation
  7. Current API429 public OpenAPI
  8. API429 public catalog contract

Put the next step into practice.

Check model IDs, current pricing and request formats before integrating. Availability can depend on the model and provider route.

Telegram