Documentation

Images

Pass images with images= next to the text context, and ask about them like any other input. Every field reads the images and the context together, and returns a typed value.

Python
response = client.generate(
    context="Read the attached photo of a restaurant receipt.",
    images=["receipt.jpg"],
    questions={
        "total": {"type": "number", "instructions": "Total in rupiah as a plain number."},
        "paid_in_cash": {"type": "boolean", "instructions": "Was the bill paid in cash?"},
    },
)
print(response.result)  # {"total": 174600, "paid_in_cash": True}

See the receipt example for the whole call on a photo, and the CV example for a page read into typed records.

To find where something is in an image, ask for a box.

What to pass

  • With the Python client, each image can be a local file path, raw bytes, a PIL image or a data: URI. No base64 needed: the client reads the file and encodes it for you.
  • The API takes images as base64 data:image/... URIs only: PNG, JPEG, GIF, WebP or BMP. It does not fetch http(s) URLs; download the image first and pass the file.
  • Over HTTP, send the URIs in images:
curl
curl https://api.typellm.ai/v1/generate \
  -H "Authorization: Bearer $TYPELLM_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "context": "Read the attached photo of a restaurant receipt.",
    "images": ["data:image/jpeg;base64,/9j/4AAQSkZJRg..."],
    "questions": {"total": {"type": "number", "instructions": "Total in rupiah as a plain number."}}
  }'

Limits and cost

  • At most 8 images per call, each up to 10 MB.
  • A larger image is scaled down to fit about 2,048 image tokens (one per 32×32 pixels) and a 2,048-pixel long edge, so small print in a large photo may need a crop.
  • Image tokens count toward usage.input_tokens and are billed as input, once per call however many fields there are.
  • An unreadable image fails with invalid_image; too many images, one too large or one that is not a data: URI with limit_exceeded.