Skip to content
SW Study Warehouse
Home › Ai
Ai

Gemini API File Slicing Controls: Cut Token Costs on PDFs, Excel & Video (2027 Guide)

By Team Study Warehouse · November 29, 2026 · 7 min read šŸ‘ 1 Views
AI engineer workstation displaying PDF layers, spreadsheet grids, and Python code for the Gemini API File Slicing guide
Disclosure: Some links in this guide are affiliate links. We may earn a commission at no extra cost to you.

Gemini API File Slicing launched on November 23, 2026, solving one of the most expensive bottlenecks in multimodal AI engineering: paying full-document token bills and maintaining heavy local rendering containers just to read three pages of a 120-page PDF, one tab of an Excel workbook, or a 30-second video clip. Alongside native upload support for Microsoft Office (.docx, .xlsx, .pptx) and OpenDocument (.odt, .ods, .odp) files across all Gemini 4 models, Google’s Files and Interactions APIs now slice, render, and tokenize targeted ranges server-side—billing you strictly for the slices the model inspects. In this developer guide from Team Study Warehouse, we break down every supported media category, exact range and layer parameters, and a complete two-stage Python workflow pairing gemini-4-hydrogen and gemini-4-neon.

Key Takeaways: Gemini API File Slicing Controls

  • Release & Model Support: Rolled out November 23, 2026, across Google AI Studio and the Gemini platform; works natively across all Gemini 4 models (including gemini-4-hydrogen, gemini-4-neon, and gemini-4-carbon).
  • Expanded File Formats: Adds native server-side ingestion for Microsoft Office and OpenDocument formats alongside PDFs, audio, and video—removing LibreOffice, PDF renderer, and ffmpeg bloat from client harnesses.
  • 14x Token Savings on Skimming: Early gateway benchmarks cited by Google showed skimming a document page via page_text used 14x fewer tokens than rendering the entire page as an image.
  • Upload Once, Slice Across Turns: Upload via client.files.upload() and reuse the returned Files API URI across user turns and function_result tool responses.

Why Server-Side File Slicing Eliminates Local Harness Bloat

Before Google’s November 23 File Slicing announcement, building an enterprise document or video agent meant maintaining brittle pre-processing pipelines inside your own backend. Developers had to bundle headless LibreOffice instances to convert .docx and .xlsx files, Poppler or PyMuPDF renderers to split PDF pages into PNGs, and ffmpeg workers to extract keyframes and audio tracks—inflating container images, filling ephemeral disks, and forcing teams to run per-user sandboxes just to slice user uploads.

With Gemini API File Slicing, you upload the raw file once via the Files API and pass its URI either in a user turn or directly inside a tool’s function_result response. Google’s servers handle rendering and tokenization using the exact layout and visual representations the Gemini 4 models were trained on, while billing tokens strictly for the requested pages, cell ranges, or timestamps. Combined with Gemini API Tool Retrieval—which we covered in our Gemini 4 Neon developer guide—teams can trim both tool-schema bloat and document-context spend in the same pipeline.

Supported Media Types, Range Controls & Content Layers

Native file slicing preserves existing file-size and page-count upload limits while exposing fine-grained controls across four media categories:

  • Documents & Slides (PDF, Word, PowerPoint, OpenDocument): Specify start_page and end_page, set visual resolution (low, medium, or high), and pick content_layers (page_text for ultra-cheap text extraction or page_image for charts, diagrams, and dense tables).
  • Spreadsheets (.xlsx, .xls, .ods): Target a specific tab with sheet_index and rectangular range with visible_cells, choose resolution (low, medium, or high), and select content_layers across data, formulas, and visuals.
  • Video Files: Clip time segments via start_offset and end_offset, tune frame sampling (fps) and resolution (low or high), and isolate content_layers (transcript, frames, or audio).
  • Audio Files: Clip exact intervals using start_offset and end_offset so long meetings or podcasts are analyzed segment by segment.

When processing options are omitted, Google applies smart defaults: documents and slides render as layout-preserving page images, and spreadsheets include evaluated values, formulas, and sheet names across all tabs.

Gemini API File Slicing Reference Table

Use the matrix below as a quick engineering reference when configuring processing options in the google-genai SDK.

Media Category Supported Formats Range & Slice Parameters Selectable Content Layers Default (Options Omitted)
Documents & Slides PDF, DOCX, PPTX, ODT, ODP start_page, end_page, resolution (low/medium/high) page_text, page_image Layout-preserving page images
Spreadsheets XLSX, XLS, ODS sheet_index, visible_cells, resolution data, formulas, visuals Evaluated values, formulas & sheet names
Video MP4, MOV, WebM, etc. start_offset, end_offset, fps, resolution (low/high) transcript, frames, audio Standard multimodal video ingestion
Audio MP3, WAV, AAC, etc. start_offset, end_offset Audio stream Full audio stream ingestion

Agentic Skim-and-Zoom Patterns & Model Routing

Because the Files API URI stays valid across turns, the highest-ROI pattern is two-stage routing. First, send the entire uploaded document to a fast, low-cost model like gemini-4-hydrogen with content_layers: ["page_text"] (or transcript for video) to locate the exact page or timestamp containing the answer. Second, pass that same URI to gemini-4-neon ($3/1M input tokens) with start_page, end_page, resolution: "high", and content_layers: ["page_image"] to inspect dense charts, footnotes, or financial tables.

This architecture also pairs naturally with OpenAI’s 272K-token tiering—which we analyzed in our GPT-6.2 Astra & Sol benchmarks guide—and browser-side agent workflows like Chrome DevTools MCP or our Google Antigravity MCP tutorial.

Step-by-Step Python Tutorial: Skim Cheap, Zoom In at High Resolution

Follow these three steps using the official google-genai Python SDK to upload a Word document once, locate a chart cheaply via text extraction, and inspect that single page at high resolution.

Step 1: Upgrade google-genai and Upload Your Office or PDF File

Install the latest SDK and upload your file once with client.files.upload():

pip install -U google-genai
export GEMINI_API_KEY="your-gemini-api-key"

Step 2: Skim Every Page Cheaply Using page_text on Gemini 4 Hydrogen

Pass "content_layers": ["page_text"] inside processing.page_options to scan all pages at minimal token cost and identify the target page number:

from google import genai

client = genai.Client()
doc = client.files.upload(file="quarterly_report.docx")
1. Skim the whole document cheaply as extracted text
skim = client.interactions.create(
model="gemini-4-hydrogen",
input=[
{
"type": "document",
"uri": doc.uri,
"mime_type": doc.mime_type,
"processing": {
"type": "static",
"page_options": {"content_layers": ["page_text"]},
},
},
{
"type": "text",
"text": "Which page has the revenue bridge chart?",
},
],
)
print(skim.output_text)

Step 3: Zoom Into the Target Page at High Resolution with Gemini 4 Neon

Reuse the exact same doc.uri without re-uploading, restrict start_page and end_page to page 3, and switch to resolution: "high" with page_image so the model reads chart labels and footnotes accurately:

# 2. Zoom into page 3 at high resolution (reusing the same URI)
detail = client.interactions.create(
    model="gemini-4-neon",
    input=[
        {
            "type": "document",
            "uri": doc.uri,
            "mime_type": doc.mime_type,
            "resolution": "high",
            "processing": {
                "type": "static",
                "page_options": {
                    "start_page": 3,
                    "end_page": 3,
                    "content_layers": ["page_image"],
                },
            },
        },
        {
            "type": "text",
            "text": "Read the revenue bridge chart and footnotes on page 3.",
        },
    ],
)
print(detail.output_text)

Frequently Asked Questions: Gemini API File Slicing

Which Gemini models support native file slicing controls?

Native file slicing controls work across all Gemini 4 models—including gemini-4-hydrogen, gemini-4-neon, and gemini-4-carbon—via Google AI Studio and the Gemini platform.

Do I still need LibreOffice or ffmpeg in my agent container?

No. The Gemini API natively slices, renders, and tokenizes PDFs, Microsoft Office (.docx, .xlsx, .pptx), OpenDocument files, audio, and video server-side once uploaded via the Files API.

How much can file slicing reduce token costs?

According to early partner benchmarks cited by Google, skimming document pages with page_text used 14x fewer tokens than rendering full pages as images, and you are billed only for the slices inspected.

What happens if I omit processing options on a file call?

When processing options are omitted, documents and slides default to layout-preserving page images, while spreadsheets include evaluated values, formulas, and sheet names across all tabs.

Can AI agents request specific file slices inside tool calls?

Yes. You can pass a Files API URI and slicing parameters directly inside a function_result tool response so your agent can inspect targeted pages, cells, or video segments on demand.

Final Verdict: Building Leaner Multimodal Agents

Gemini API File Slicing turns multimodal ingestion from a brute-force token expense into an on-demand retrieval step. By uploading Office, PDF, audio, or video files once to the Files API, skimming cheaply with gemini-4-hydrogen on page_text or transcript layers, and zooming in at high resolution with gemini-4-neon only on the exact pages or timestamps that matter, engineering teams can retire brittle local LibreOffice/ffmpeg workers while cutting document token spend dramatically.

Found this guide helpful? Support Team StudyWarehouse! Buy Us a Coffee

Team Study Warehouse

Tech editor and WordPress developer at StudyWarehouse.com sharing hosting benchmarks, theme reviews, and practical tutorials.

Leave a Reply

Your email address will not be published. Required fields are marked *