Vision

Vision models can look at images as well as read text. Use them to describe photos, read charts and diagrams, or pull the text out of a screenshot or scan.

Send an image

Add the image to a normal chat message as an image_url part. You can mix text and images in the same message.

from pendra import Pendra

client = Pendra(api_key="pdr_sk_...")

response = client.chat.completions.create(
    model="gemma4:12b",
    messages=[{
        "role": "user",
        "content": [
            {"type": "text", "text": "What's in this image?"},
            {"type": "image_url",
             "image_url": {"url": "data:image/png;base64,iVBORw0..."}},
        ],
    }],
)
print(response.choices[0].message.content)
The image sent to the model
Response

A vivid impressionist oil painting of rolling hills at sunset, built up in thick palette-knife strokes of orange, yellow, and blue. A winding path leads through fields towards the hills, with a few small figures walking along it and autumn trees and a wooden fence in the foreground.

Images you can send

  • Formats: PNG, JPEG, GIF, BMP and WebP.
  • Base64 (data:image/png;base64,…) always works, and the image never leaves your request.
  • Image URLs are off until you turn them on in the worker's settings.

Use a model with vision in its capabilities, shown in the models list. Sending an image to a model that can't see returns an error.

Screenshots from tools

An agent can return a screenshot as a tool result, and the model sees it the same way. Put the image parts in the tool message's content. If the model can't see images, it gets the text [image omitted] instead, and the request still works.

Lots of images

There's no fixed limit on images, but one request can hold about 30 full-HD screenshots. In a longer conversation, Pendra swaps the oldest images for [image omitted] and tells you how many under pendra.images_omitted in the reply. Your latest message is never trimmed, so resend an older image there if the model needs it.

A whole request can be up to 39 MB, including base64 images. Send screenshots as JPEG or WebP rather than PNG to stay well under it.

Troubleshooting

  • 415 means the image format isn't supported. Convert it to PNG, JPEG or WebP.
  • 413 means the request is over 39 MB.
  • 400 means your latest message has too many images to read at once. Send fewer or smaller ones.
  • 507 means the GPU had no room to read the image. The model still answers text.
  • If Vision is crossed out for a model on the Workers page, hover it to see why. Reinstalling the model often fixes it.
For the full message format, see the Chat completions API reference.