AI / Google Antigravity Gemini Fundamentals Interview Questions
What is the Gemini Batch API and when should you use it?
The Batch API allows submitting multiple Gemini API requests as an asynchronous batch job, receiving results up to 24 hours later at approximately 50% reduced cost compared to synchronous API calls. It is designed for large-scale, non-time-sensitive workloads.
from google import genai from google.genai import types client = genai.Client() # Create a batch job with multiple requests: batch = client.batches.create( model="gemini-2.5-flash", src=types.CreateBatchJobSource( requests=[ types.EmbedContentRequest( content=types.Content(parts=[types.Part(text="Summarise: " + doc)]) ) for doc in list_of_1000_documents ] ), ) print(f"Batch ID: {batch.name}, state: {batch.state}") # Poll for completion (up to 24 hours): import time while batch.state in ("JOB_STATE_PENDING", "JOB_STATE_RUNNING"): time.sleep(60) batch = client.batches.get(name=batch.name) # Retrieve results: for result in client.batches.list_responses(name=batch.name): print(result.response.candidates[0].content.parts[0].text) # All current Gemini 3 and 2.5 models support the Batch API
| Aspect | Synchronous | Batch API |
|---|---|---|
| Cost | Standard pricing | ~50% reduction |
| Latency | Real-time (seconds) | Up to 24 hours |
| Rate limits | Against RPM/TPM | Separate higher batch limits |
| Use cases | Interactive apps | Evals, bulk analysis, dataset processing |
More Related questions...