返回资讯中心
外部精选
软件工程
#开发者实时流

File slicing controls in the Gemini API

The Gemini API now features native file slicing controls, allowing developers to specify targeted pages, sheet ranges, and media segments for the model to load server-side. This capability reduces token costs for large …

Hacker News 最新pretext2026/11/23 · 今天9 分钟阅读

以下正文同步自 Hacker News 最新,版权归原站所有,已转换为易读排版。

The Gemini API now features native file slicing controls, allowing developers to specify targeted pages, sheet ranges, and media segments for the model to load server-side. This capability reduces token costs for large files.

Your browser does not support the audio element.

Today, we're launching new file slicing controls in the API across Google AI Studio and Gemini platform, alongside native file upload support for Microsoft Office and OpenDocument formats. You can now pass PDFs, Office files (docs, slides, spreadsheets), audio, and video directly to the Gemini API and request only the pages, spreadsheet cells, media segments, and layers you need. This keeps context focused on the relevant parts of a file while billing tokens only for the parts Gemini inspects.

Real-world knowledge work lives in dense PDFs, slide decks, multi-tab workbooks, and long recordings. With server-side slicing, you do not have to flatten files to plain text or ingest entire files up front.

Slice documents, spreadsheets, and videos and more by range, layer, resolution, and frame rate to control token usage.

When model APIs only ingest whole files, agents end up running LibreOffice, PDF renderers, and ffmpeg inside the client harness to render and slice large files. This bloats memory, clutters local disk with extracted frames, and forces enterprise platforms to maintain per-user sandboxes just to slice files. With the Gemini API, pass a Files API URI on a user turn or directly inside a function response (function_result), and the API natively slices, renders, and tokenizes each file server-side the way the model was trained to see it.

Native file slicing works across all Gemini 4 models, and existing file size and page limits still apply to the uploaded file. You can customize processing across these media categories:

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

Upload a Word document once to the Files API, skim every page cheaply as extracted text to locate the right section, then reuse the same URI to inspect a single page at high resolution:

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)

2. Zoom into the target page 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)

Early adoption across agent frameworks

Gateway and SDK partners validated these controls ahead of launch, cutting prompt token spend directly in production harnesses:

Native file slicing, content-layer controls, and expanded files support are available today via the API in Google AI Studio and the Gemini platform. Check out our docs to start building.

正文由 探How 从来源站点 RSS 同步,内容未经改写;遇到排版缺失或需要图片、视频时请以原文为准。

打开原文
去社区讨论 →