Gemini · Coding

Large-context code

Find out how much code fits on your plan, import a repo instead of pasting it, put your question last, and cut repeat costs on the API.

Gemini large-context code

Big window, real limits

A 1 million token window lets you ask questions that cross a whole service, but a successful upload doesn't mean all of it was used. Google's upload limit of 100 MB is far more text than 1 million tokens, which is only about 4 MB at Google's estimate of 4 characters per token. So measure first. This lesson shows how to estimate your repo's size, how to arrange a long prompt, and what to do when you're asking many questions.

App or API?

In the app, you import a folder and your plan's limits apply. On the API, you pay per token, you can count tokens exactly with count_tokens, and caching can reduce the cost of repeat questions. Budgets differ by model too. On Gemini 4 Argon, input, thinking and output share one 1 million token window, while Gemini 3 and 2.5 have separate input and output budgets.

Frequently asked
How big is Gemini's context window?

In the app, 32k tokens with no plan, 128k on Google AI Plus, and 1 million on Google AI Pro and Ultra. On the API, Gemini 4 Argon has a 1 million token window shared across input, thinking and output.

How many lines of code fit in Gemini?

Google's estimates differ. Its app help says 1 million tokens is roughly 30,000 lines of code, and its API docs say 50,000 lines at 80 characters each. Measure your own code by dividing its size in bytes by 4.

Does Gemini read my whole codebase?

Only what fits in the context window. Google warns that going over can cause answers to miss details spread through large files, and an upload can succeed even if it's too big for your plan's window. Ask Gemini which folders it didn't read.