SPB Git

Repository Public

priority-inference.md 6.9 KB 161 lines markdown

1<br />23Description: Learn how to optimize latency with the Priority inference tier in the Interactions API45<br />678> [!WARNING]9> **Preview:** The Gemini Priority API is in [Preview](https://cloud.google.com/products#product-launch-stages).1011The Gemini Priority API is a premium inference tier designed for12business-critical workloads that require lower latency and the highest13reliability at a premium price point. Priority tier traffic is prioritized above14standard API and Flex tier traffic.1516Priority inference is available across the Interactions API endpoints.1718## How to use Priority1920To use the Priority tier, set the `service_tier` field in your request to `priority`. The default tier is standard if the field is omitted.2122### Python2324    from google import genai2526    client = genai.Client()2728    interaction = client.interactions.create(29        model="gemini-3.8-flash",30        input="Triage this critical customer support ticket immediately.",31        service_tier='priority'32    )33    print(interaction.output_text)3435### JavaScript3637    import { GoogleGenAI } from '@google/genai';3839    const ai = new GoogleGenAI({});4041    async function main() {42        const interaction = await ai.interactions.create({43            model: "gemini-3.8-flash",44            input: "Triage this critical customer support ticket immediately.",45            service_tier: "priority"46        });47        console.log(interaction.output_text);48    }4950    await main();5152### Java5354    import com.google.genai.Client;55    import com.google.genai.gaos.models.interactions.CreateModelInteraction;56    import com.google.genai.gaos.models.interactions.Interaction;57    import com.google.genai.gaos.models.interactions.InteractionsInput;58    import com.google.genai.gaos.models.interactions.Model;59    import com.google.genai.gaos.models.interactions.ServiceTier;60    import com.google.genai.gaos.models.operations.CreateInteractionRequestBody;6162    Client client = new Client();6364    CreateModelInteraction params =65        CreateModelInteraction.builder()66            .model(Model.of("gemini-3.8-flash"))67            .input(InteractionsInput.of("Perform a priority inference task."))68            .serviceTier(ServiceTier.PRIORITY)69            .build();7071    Interaction interaction =72        client.interactions.create(CreateInteractionRequestBody.of(params)).interaction().get();7374    System.out.println(interaction.outputText().orElse(""));7576### REST7778    curl -X POST "https://generativelanguage.googleapis.com/v1beta/interactions" \79      -H "Content-Type: application/json" \80      -H "x-goog-api-key: $GEMINI_API_KEY" \81      -d '{82        "model": "gemini-3.8-flash",83        "input": "Triage this critical customer support ticket immediately.",84        "service_tier": "priority"85      }'8687## How Priority inference works8889Priority inference routes requests to high-criticality compute queues, offering90predictable, fast performance for user-facing applications. Its primary91mechanism is a graceful server-side downgrade to standard processing for traffic92that exceeds dynamic limits, ensuring application stability instead of failing93the request.9495| Feature | Priority | Standard | Flex | Batch |96|---|---|---|---|---|97| **Pricing** | 75-100% more than Standard | Full price | 50% discount | 50% discount |98| **Latency** | Seconds | Seconds to minutes | Minutes (1--15 min target) | Up to 24 hours |99| **Reliability** | High (Non-sheddable) | High / Medium-high | Best-effort (Sheddable) | High (for throughput) |100| **Interface** | Synchronous | Synchronous | Synchronous | Asynchronous |101102### Key benefits103104- **Low latency**: Designed for second response times for interactive, user-facing AI tools.105- **High reliability**: Traffic is treated with the highest criticality and is strictly non-sheddable.106- **Graceful degradation**: Traffic spikes exceeding dynamic limits are automatically downgraded to the Standard tier for processing instead of failing, preventing service outages.107- **Low friction** : Uses the same synchronous `create` method as the standard and Flex tiers.108109### Use cases110111Priority processing is ideal for business-critical workflows where performance112and reliability are paramount.113114- **Interactive AI applications**: Customer service chatbots and copilots where users pay a premium and expect fast, consistent responses.115- **Real-time decision engines**: Systems requiring highly reliable, low-latency outcomes, such as live ticket triaging or fraud detection.116- **Premium customer features**: Developers who need to guarantee higher service level objectives (SLOs) for paying customers.117118### Rate limits119120Priority consumption holds its own rate limits even though consumption is121counted towards [overall interactive traffic rate limits](https://aistudio.google.com/rate-limit). The default rate limits122for Priority inference are **0.3x standard rate limit for Model / Tier**123124### Graceful downgrade logic125126If Priority limits are exceeded due to congestion, overflow requests are127**automatically and gracefully** downgraded to Standard processing instead of128failing with a 503 or 429 error. Downgraded requests are billed at the standard129rate, not the Priority premium rate.130131### Client responsibility132133- **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`.134- **Retries** : Clients must implement retry logic/exponential backoff for standard errors, such as `DEADLINE_EXCEEDED`.135136## Pricing137138Priority inference is priced at 75-100% more than the [standard API](https://ai.google.dev/gemini-api/docs/pricing) and billed per token.139140## Supported models141142The following models support Priority inference:143144| Model | Priority inference |145|---|---|146| [Gemini 3.8 Flash](https://ai.google.dev/gemini-api/docs/models/gemini-3.8-flash) | ✔️ |147| [Gemini 3.7 Flash](https://ai.google.dev/gemini-api/docs/models/gemini-3.7-flash) | ✔️ |148| [Gemini 3.6 Flash](https://ai.google.dev/gemini-api/docs/models/gemini-3.6-flash) | ✔️ |149| [Gemini 3.5 Flash-Lite](https://ai.google.dev/gemini-api/docs/models/gemini-3.5-flash-lite) | ✔️ |150| [Gemini 3.5 Flash](https://ai.google.dev/gemini-api/docs/models/gemini-3.5-flash) | ✔️ |151| [Gemini 3.1 Flash-Lite](https://ai.google.dev/gemini-api/docs/models/gemini-3.1-flash-lite) | ✔️ |152| [Gemini 3.1 Pro Preview](https://ai.google.dev/gemini-api/docs/models/gemini-3.1-pro-preview) | ✔️ |153| [Gemini 3 Flash Preview](https://ai.google.dev/gemini-api/docs/models/gemini-3-flash-preview) | ✔️ |154| [Gemini 2.5 Pro](https://ai.google.dev/gemini-api/docs/models/gemini-2.5-pro) | ✔️ |155| [Gemini 2.5 Flash](https://ai.google.dev/gemini-api/docs/models/gemini-2.5-flash) | ✔️ |156| [Gemini 2.5 Flash-Lite](https://ai.google.dev/gemini-api/docs/models/gemini-2.5-flash-lite) | ✔️ |157158## What's next159160- [Flex inference](https://ai.google.dev/gemini-api/docs/flex-inference) for cost reduction.161- [Tokens](https://ai.google.dev/gemini-api/docs/tokens): Understand tokens.
Files main
Menu

Theme