Vision and file input

Send images, text files and PDFs alongside a prompt.

Send an image with a question

Pass an array of parts in the user message. Replace the example URL with a public HTTPS image.

JSON
{
  "model": "google/gemma-4-E2B-it",
  "messages": [{
    "role": "user",
    "content": [
      {"type": "text", "text": "Describe the labels in this image."},
      {"type": "image_url", "image_url": {"url": "https://your-site.example/chart.png"}}
    ]
  }],
  "max_tokens": 512
}

PNG, JPEG, WebP and GIF are supported as inputs. GIF image input uses its first frame. You can also use a base64 data URL such as data:image/png;base64,....

Send a text file or PDF

Inline UTF-8 text is useful for small files.

JSON
{
  "model": "deepseek-v4.1-flash-1017",
  "messages": [{
    "role": "user",
    "content": [
      {"type": "text", "text": "Extract the meeting time."},
      {"type": "file", "file": {"filename": "meeting-notes.txt", "text": "The meeting starts at 10:30."}}
    ]
  }],
  "max_tokens": 128
}

For a PDF or encoded file, supply file_data as base64 or a data URL, or file_url as a public HTTPS URL. For Responses use input_image and input_file. Anthropic Messages uses image and document blocks; Ollama uses images.

PDFs need extractable text and must be unencrypted. Send scans as page images. The text reader supports UTF-8 text, code, JSON, CSV and Markdown. This input pipeline is for images and readable documents; image output has its own endpoints.

Limits and metadata

Send up to 16 attachments, 4 MiB per attachment and 8 MiB per JSON request. Images are limited to 32 megapixels and PDFs to 100 pages and 262,144 extracted characters.

input_processing can identify how an attachment was handled, including a vision reader when a text model receives observations. Use a model with native vision when the precise details of the image matter.

Search the docs