AI / Google Antigravity Gemini Fundamentals Interview Questions
What is the Gemini context window and how do you manage long contexts?
The context window is the maximum number of tokens a model can process in a single request (input + output combined). Gemini models have among the largest context windows of any commercially available AI, with 1 million tokens for most current models.
| Model | Input context | Max output |
|---|---|---|
| Gemini 3.5 Flash | 1 million tokens | 64k tokens |
| Gemini 3.1 Pro Preview | 1 million tokens | 64k tokens |
| Gemini 2.5 Pro | 1 million tokens | 64k tokens |
| Gemini 2.5 Flash | 1 million tokens | 64k tokens |
from google import genai from google.genai import types client = genai.Client() # Count tokens before sending (avoid context overflow errors): token_response = client.models.count_tokens( model="gemini-3.5-flash", contents="Your very long document here...", ) print(f"Token count: {token_response.total_tokens}") # check vs 1M limit # Long context use cases Gemini excels at: # 1. Entire codebase analysis response = client.models.generate_content( model="gemini-3.5-flash", contents=[ "Summarise all TODO comments in this codebase and prioritise them.", entire_codebase_text, # can be hundreds of files ] ) # 2. Full book Q&A # 3. Hour-long video analysis # 4. Full conversation history # Context caching: cache large stable prompts to reduce cost: cached = client.caches.create( model="gemini-3.5-flash", contents=[large_document], # cache this expensive prefix ttl="3600s", ) # Reference the cache in subsequent calls: response = client.models.generate_content( model="gemini-3.5-flash", contents="Summarise section 3.", config=types.GenerateContentConfig(cached_content=cached.name), )
More Related questions...