Skip to main content
The Gemini native format accepts images, audio, and video directly for understanding and analysis, and ships a built-in code_execution tool that runs Python in a sandbox. Examples below assume the client setup from Native Calls.
Two hard limits on the APIYI channel:
  1. The Files API is not supported (client.files.upload() works only on Google’s official endpoint) — media must be passed inline
  2. Inline media is capped at 20MB per file; compress or extract frames first if larger

Image Understanding

Pass a PIL Image directly — the SDK handles encoding:
Or pass bytes explicitly with types.Part.from_bytes:

Audio Understanding

Video Understanding

Video is tokenized per frame plus the audio track — longer videos get expensive. More video workflows: Video Understanding.

Cost Control with media_resolution

Token consumption for media scales with resolution. For “rough look” tasks (classification, presence checks), lower resolution saves real money:

Supported Formats

All inline, max 20MB per file.

Code Execution

Declare the code_execution tool and the model writes Python, runs it in a sandbox, and answers based on the result — ideal for calculations and data analysis:
Code execution limits: Python only; the sandbox has no network or filesystem access; execution time is capped. To call your own external services, use Function Calling.