Lesson 27.4 · 4 of 5 · 6 min read · Reviewed 24 Nov 2026
Page images as multimodal input
By the end, you can
- Decide when to send page images to a multimodal model instead of extracted text.
- Estimate the token cost of page images and design a hybrid pipeline.
Skip the parser, show the page
Lessons 27.1 to 27.3 rebuild structure from a PDF so a model can read text. There is another route: render each page as an image and give the image to a vision-capable model. The model sees the page as a person does, columns, tables, charts and stamps included.
Many model APIs accept images in a message, and some accept a whole PDF and handle the page images for you. Either way, the idea is the same:
{"role": "user", "content": [
{"type": "image", "source": {"type": "base64", "media_type": "image/png", "data": "<page 12 as PNG>"}},
{"type": "text", "text": "This is page 12 of the 2025 report. Extract the table as Markdown and describe Figure 3."}
]}
What it costs
Images are turned into tokensToken: The unit a model reads and writes: a word, part of a word, a space or a symbol, mapped to an integer id. too. Providers publish rules of thumb; for example, Claude’s docs give an estimate based on the image’s width times height. A full page image at readable resolution often costs several times the tokens of the same page’s extracted text, and the model takes longer to read it.
Worked example with illustrative numbers: a page has about 600 tokens of text, and its image costs about 1,800 tokens.
| Approach | 200-page report | Relative input |
|---|---|---|
| Extracted text only | 200 x 600 = 120,000 tokens | 1x |
| Page images only | 200 x 1,800 = 360,000 tokens | 3x |
| Text, plus images for 20 hard pages | 120,000 + 20 x 1,800 = 156,000 tokens | 1.3x |
Resolution matters: too low and small print becomes unreadable; too high and you pay for pixels that add nothing. Test a few sizes on your hardest pages.
Three ways to use page images
- Parse with visionVision: A model’s ability to read and reason about images, such as screenshots, charts and photos., once. At indexing time, send hard pages to a vision model and ask for structured text: Markdown tables, figure descriptions (27.3). Index that text as usual.
- Answer with vision. Retrieve with text as normal, then send the images of the retrieved pages to the model with the question. It sees the original layout when it answers and can cite the page.
- Retrieve with vision. Some retrievers, such as the ColPali approach, embed page images directly and search over them, so no text extraction is needed for search.
When to use it
| Use page images when | Stay with text when |
|---|---|
| Charts, diagrams or maps carry the meaning | Pages are clean digital prose |
| Scans or photos with poor OCR | Volume is huge and budget is tight |
| Complex forms, stamps or handwriting | You need exact text for search and quotes |
| Layout itself is the question (“which box is ticked?”) | Latency must be low |
Common mistakes
- Sending every page as an image “to be safe” and multiplying cost for no gain.
- Forgetting the page number: tell the model which page each image is, so it can cite it.
- Trusting numbers a model reads off a chart as exact. Ask for approximate values, and prefer source data when it exists.
- Down-scaling images until small print is lost, then blaming the model.
Key points
- A vision-capable model can read a rendered page image directly, including charts, scans and odd layouts.
- Page images usually cost several times more tokens than the page's extracted text, and they are slower.
- A hybrid is common: index extracted text, and send page images only for pages that need them or for the pages retrieved.
- Some retrievers embed page images themselves, skipping text extraction for search.
Budget tokens for page images
Compare the token cost of text, page images and a hybrid, and build the multimodal message for only the pages that need images.
You will have: A cost table for three strategies and a message payload that sends page images for the hard pages only, each labelled with its page number.
Steps
- Read the page list: each page has a text token count and a flag for charts or scans.
- Compute total input tokens for text only, images only and the hybrid, using an illustrative 1,800 tokens per page image.
- Print each total and its ratio to text only.
- Build a user message whose content has, for each hard page, a text block naming the page and an image block with placeholder data.
- Check the message contains one image block per hard page and nothing for easy pages.
Done when
- Hybrid costs less than images only and more than text only.
- The message has exactly 3 image blocks for the 3 hard pages.
- Every image block is preceded by a text block that names its page.
Open in the Playground No API key needed.
Starter code (Python)
IMAGE_TOKENS = 1800
PAGES = [{"page": i, "text_tokens": 600, "hard": i in (4, 9, 12)} for i in range(1, 21)]
def totals(pages):
# TODO: return dict with "text only", "images only" and "hybrid" totals
return {"text only": 0, "images only": 0, "hybrid": 0}
def build_message(pages):
content = []
# TODO: for each hard page add {"type": "text", "text": "Page N:"} then an image block
content.append({"type": "text", "text": "Describe any tables or charts on these pages, citing page numbers."})
return {"role": "user", "content": content}
for name, t in totals(PAGES).items():
print(f"{name:12} {t:>8,}")
msg = build_message(PAGES)
print("blocks:", [b["type"] for b in msg["content"]])
Show a solution
IMAGE_TOKENS = 1800
PAGES = [{"page": i, "text_tokens": 600, "hard": i in (4, 9, 12)} for i in range(1, 21)]
def totals(pages):
text = sum(p["text_tokens"] for p in pages)
images = IMAGE_TOKENS * len(pages)
hybrid = text + IMAGE_TOKENS * sum(p["hard"] for p in pages)
return {"text only": text, "images only": images, "hybrid": hybrid}
def build_message(pages):
content = []
for p in pages:
if p["hard"]:
content.append({"type": "text", "text": f"Page {p['page']}:"})
content.append({"type": "image", "source": {"type": "base64", "media_type": "image/png", "data": f"<page {p['page']} PNG>"}})
content.append({"type": "text", "text": "Describe any tables or charts on these pages, citing page numbers."})
return {"role": "user", "content": content}
t = totals(PAGES)
for name, v in t.items():
print(f"{name:12} {v:>8,} tokens {v / t['text only']:.2f}x")
msg = build_message(PAGES)
images = [b for b in msg["content"] if b["type"] == "image"]
labels = [msg["content"][i - 1]["text"] for i, b in enumerate(msg["content"]) if b["type"] == "image"]
print(f"image blocks: {len(images)} labelled: {labels}")