Reduce Gemini API token costs by slicing files server-side before analysis

Reduce Gemini API token costs by slicing files server-side before analysis

AI-generated illustration, not a screenshot or evidence of a real test.

If you only need three pages of a report, sending all 100 pages to an AI model can be unnecessary. Google's November 23 update adds server-side file slicing to the Gemini API: you can select the part to process instead of preparing a separate file locally. I would try it first on a task where the relevant pages are already known, because choosing the wrong slice can remove the evidence needed for a good answer.

The official announcement describes lower token costs for large files. That is a vendor claim about the feature, not a saving measured in this article. Here is a small, reversible way to decide whether it helps your own PDF workflow.

The useful change is selecting what the model reads

The new control moves file selection into the API request. Instead of creating a separate PDF for each section you want analyzed, you can identify a page range in the request. Google's document-processing guide says the model counts and bills tokens for the selected slice.

That distinction matters: selecting pages for analysis is not the same as reducing the size of the original file. It also does not establish that an answer will be faster or more accurate. Those outcomes need their own checks.

For example, imagine a 100-page report whose relevant table is on pages 14–16. Selecting those pages is a reasonable starting point if the table stands on its own. If its definitions or qualifications appear elsewhere, a smaller input may produce a less complete answer. The useful question is therefore not just “How many tokens disappeared?” but “Did the smaller input preserve what the task needed?”

Start with a known page range

This is an API workflow. It is not a claim that the same controls appear in the consumer Gemini chat interface. The current processing guide lists Gemini 3 and Gemini 4 support; it does not justify the narrower claim that Gemini 4 is always required.

  1. Choose one non-sensitive PDF and a question whose answer you can check against it. Write down the relevant page range before comparing outputs.
  2. For a small local PDF, start with the inline example in Google's file-input guide, which specifies a 50MB PDF limit for that method. If you already have a working file-input method, keep it for both comparison runs. Slicing does not replace input limits or make an unsupported file valid.
  3. Open the Python example under “Slice pages and select content layers” in the processing guide. Use its documented request shape rather than inventing a field called pages or cell_range.
  4. For PDF pages, the documented controls are processing.type set to static, with page_options.start_page and page_options.end_page. The example also shows how resolution and content layers are specified. Keep those choices explicit.
  5. Read the response against the selected pages and the surrounding report. Check whether the answer lost a definition, qualification or referenced table.

I prefer linking the maintained example here to presenting an untested request as ready to run. You still need the client setup, a supported model and an accessible file; copying a short snippet cannot establish that those conditions are met.

Compare one change, not two different setups

The following is a proposed test, not an experiment we have run. Make a full-document request and a selected-page request using the same file, model, question, resolution and content-layer choices. Change only the page selection. Record the input-token usage reported by the API and compare the answers against the same source material.

Do not predict a percentage saving from the page count alone. Three pages out of 100 may contain very different amounts of text, charts or images from the rest of the report. The documentation's billing rule is a reason to measure the result, not evidence for a particular ratio in your file.

A cheaper answer that misses an important footnote is not an improvement. Keep a short list of facts the answer must retain, then inspect both outputs for omissions and unsupported additions. If the selected range is incomplete, widen it or keep the full-document request.

When I would keep the current workflow

I would keep the full file when the job is to discover relevant evidence across the whole report, rather than analyze a section already located. Otherwise, selecting the pages can quietly assume the very answer the AI was meant to help find.

For repeated analysis of a known section, slicing is worth a limited trial. Move one workflow only after the selected-page request preserves the required facts and produces a useful reduction in recorded input usage. Until then, keep the existing request as the fallback.

This is a source synthesis of Google's announcement and documentation, checked on November 30, 2026. We have not measured cost, latency or answer quality for this feature. If any required fact disappears from the sliced answer, stop that trial and restore the full-document request before applying it to more reports.

Korean Notes (한국어 참고)

  • Gemini API에서 PDF의 필요한 페이지만 지정해 분석하는 기능입니다. 일반 채팅 앱의 기능과 구분해야 해요.
  • 공식 문서는 Gemini 3·4 지원을 안내합니다. Gemini 4만 필요하다고 단정할 근거는 없습니다.
  • 같은 파일·모델·질문으로 전체 문서와 일부 페이지를 비교하세요. 비용 절감률을 직접 측정한 글은 아닙니다.
  • 필요한 근거가 문서 어디에 있는지부터 찾아야 한다면 전체 문서를 유지하는 편이 낫다고 봅니다.

Sources Consulted

Comments