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 |
Invest now in Acorns!!! 🚀
Join Acorns and get your $5 bonus!
Acorns is a micro-investing app that automatically invests your "spare change" from daily purchases into diversified, expert-built portfolios of ETFs. It is designed for beginners, allowing you to start investing with as little as $5. The service automates saving and investing. Disclosure: I may receive a referral bonus.
Invest now!!! Get Free equity stock (US, UK only)!
Use Robinhood app to invest in stocks. It is safe and secure. Use the Referral link to claim your free stock when you sign up!.
The Robinhood app makes it easy to trade stocks, crypto and more.
Webull! Receive free stock by signing up using the link: Webull signup.
More Related questions...
