SPB Git

Repository Public

priority-inference.md 6.1 KB 144 lines markdown

1# Priority inference23> [!NOTE]4> **Note** : This version of the page covers the new [Interactions API](https://ai.google.dev/gemini-api/docs/interactions/interactions-overview), which is currently in Beta.  5> For stable production deployments, we recommend you continue to use the `generateContent` API. You can use the toggle on this page to switch between the versions.67> [!WARNING]8> **Preview:** The Gemini Priority API is in [Preview](https://cloud.google.com/products#product-launch-stages).910The Gemini Priority API is a premium inference tier designed for11business-critical workloads that require lower latency and the highest12reliability at a premium price point. Priority tier traffic is prioritized above13standard API and Flex tier traffic.1415Priority inference is available across the Interactions API endpoints.1617## How to use Priority1819To use the Priority tier, set the `service_tier` field in your request to `priority`. The default tier is standard if the field is omitted.2021### Python2223    from google import genai2425    client = genai.Client()2627    try:28        interaction = client.interactions.create(29            model="gemini-3.5-flash",30            input="Triage this critical customer support ticket immediately.",31            service_tier='priority'32        )3334        print(interaction.output_text)3536    except Exception as e:37        print(f"Error during API call: {e}")3839### JavaScript4041    import { GoogleGenAI } from '@google/genai';4243    const ai = new GoogleGenAI({});4445    async function main() {46      try {47          const interaction = await ai.interactions.create({48              model: "gemini-3.5-flash",49              input: "Triage this critical customer support ticket immediately.",50              service_tier: "priority"51          });5253          console.log(interaction.output_text);5455      } catch (e) {56          console.log(`Error during API call: ${e}`);57      }58    }5960    await main();6162### REST6364    curl -X POST "https://generativelanguage.googleapis.com/v1beta/interactions" \65      -H "Content-Type: application/json" \66      -H "x-goog-api-key: $GEMINI_API_KEY" \67      -H "Api-Revision: 2026-05-20" \68      -d '{69        "model": "gemini-3.5-flash",70        "input": "Triage this critical customer support ticket immediately.",71        "service_tier": "priority"72      }'7374## How Priority inference works7576Priority inference routes requests to high-criticality compute queues, offering77predictable, fast performance for user-facing applications. Its primary78mechanism is a graceful server-side downgrade to standard processing for traffic79that exceeds dynamic limits, ensuring application stability instead of failing80the request.8182| Feature | Priority | Standard | Flex | Batch |83|---|---|---|---|---|84| **Pricing** | 75-100% more than Standard | Full price | 50% discount | 50% discount |85| **Latency** | Seconds | Seconds to minutes | Minutes (1--15 min target) | Up to 24 hours |86| **Reliability** | High (Non-sheddable) | High / Medium-high | Best-effort (Sheddable) | High (for throughput) |87| **Interface** | Synchronous | Synchronous | Synchronous | Asynchronous |8889### Key benefits9091- **Low latency**: Designed for second response times for interactive, user-facing AI tools.92- **High reliability**: Traffic is treated with the highest criticality and is strictly non-sheddable.93- **Graceful degradation**: Traffic spikes exceeding dynamic limits are automatically downgraded to the Standard tier for processing instead of failing, preventing service outages.94- **Low friction** : Uses the same synchronous `create` method as the standard and Flex tiers.9596### Use cases9798Priority processing is ideal for business-critical workflows where performance99and reliability are paramount.100101- **Interactive AI applications**: Customer service chatbots and copilots where users pay a premium and expect fast, consistent responses.102- **Real-time decision engines**: Systems requiring highly reliable, low-latency outcomes, such as live ticket triaging or fraud detection.103- **Premium customer features**: Developers who need to guarantee higher service level objectives (SLOs) for paying customers.104105### Rate limits106107Priority consumption holds its own rate limits even though consumption is108counted towards [overall interactive traffic rate limits](https://aistudio.google.com/rate-limit). The default rate limits109for Priority inference are **0.3x standard rate limit for Model / Tier**110111### Graceful downgrade logic112113If Priority limits are exceeded due to congestion, overflow requests are114**automatically and gracefully** downgraded to Standard processing instead of115failing with a 503 or 429 error. Downgraded requests are billed at the standard116rate, not the Priority premium rate.117118### Client responsibility119120- **Response monitoring** : Developers should monitor the `x-gemini-service-tier` header in the API response to detect if requests are being frequently downgraded to `standard`.121- **Retries** : Clients must implement retry logic/exponential backoff for standard errors, such as `DEADLINE_EXCEEDED`.122123## Pricing124125Priority inference is priced at 75-100% more than the [standard API](https://ai.google.dev/gemini-api/docs/pricing) and billed per token.126127## Supported models128129The following models support Priority inference:130131| Model | Priority inference |132|---|---|133| [Gemini 3.5 Flash](https://ai.google.dev/gemini-api/docs/models/gemini-3.5-flash) | ✔️ |134| [Gemini 3.1 Flash-Lite](https://ai.google.dev/gemini-api/docs/models/gemini-3.1-flash-lite) | ✔️ |135| [Gemini 3.1 Pro Preview](https://ai.google.dev/gemini-api/docs/models/gemini-3.1-pro-preview) | ✔️ |136| [Gemini 3 Flash Preview](https://ai.google.dev/gemini-api/docs/models/gemini-3-flash-preview) | ✔️ |137| [Gemini 2.5 Pro](https://ai.google.dev/gemini-api/docs/models/gemini-2.5-pro) | ✔️ |138| [Gemini 2.5 Flash](https://ai.google.dev/gemini-api/docs/models/gemini-2.5-flash) | ✔️ |139| [Gemini 2.5 Flash-Lite](https://ai.google.dev/gemini-api/docs/models/gemini-2.5-flash-lite) | ✔️ |140141## What's next142143- [Flex inference](https://ai.google.dev/gemini-api/docs/interactions/flex-inference) for cost reduction.144- [Tokens](https://ai.google.dev/gemini-api/docs/interactions/tokens): Understand tokens.
Files main
Menu

Theme