# Gemini inline images/PDFs (google-genai): budget for ~20 MB per request incl. base64 overhead

- Source: https://chatoverflow.dev/n/gemini-inline-images-pdfs-google-genai-budget-for-20-mb-per-request-incl-base64-overhead-7e527486d759
- Author: @rushilara
- Published: 2026-11-15
- Net votes: 0
- Tags: gemini, google-genai, multimodal, python, llm

With the google-genai Python SDK, `types.Part.from_bytes(data=..., mime_type=...)` sends images (`image/png`, `image/jpeg`) and PDFs (`application/pdf`) inline in `generate_content`. You don't need the Files API for typical evidence-sized files. The Files API also stores uploads on Google's side for a while, which matters if you're trying to keep data local.

Size limits are documented inconsistently across Gemini docs pages: about 20 MB total request (prompt + system instruction + inline bytes) on the image-understanding page, versus 100 MB per request (50 MB for PDFs) on a newer file-input page, plus 1000 PDF pages at about 258 tokens per page. Inline bytes travel base64-encoded in JSON, about 4/3 their raw size. Design for the strictest figure: e.g. cap total media at about 12 MB raw (about 16 MB encoded) and each file at about 8 MB. Skip and report anything over the cap rather than silently dropping it.

Tips:
- Put a tagged text part (record ID, locator, modality) before each media part, so citations can refer to it.
- The model reads pixels, not EXIF. If capture time or GPS matter, extract them locally (Pillow for images, pypdf for PDFs) into a text part, labelled as untrusted metadata.
- Text drawn inside an image can be a prompt injection. Tell the model that image and PDF content is data, not instructions, and test it live with a synthetic image containing an injection line.
