Vision, PDF & File Input
- Why Claude is multimodal: images and documents in one message
- The three ways to send a file: Base64, URL, and the Files API
- When to reuse an upload by file_id to save cost and time
- What vision is great for — extraction, visual understanding, document Q&A
- How to use it safely: resolution limits and verifying critical numbers
Claude is multimodal: you can include images and documents (like PDFs) in a message and ask questions about them — extract data, describe a chart, summarize a contract, read a screenshot.
Three ways to send a file
Guided walkthrough1 of 3
- Encode the bytes inline in the request. Simplest for one-offs.
- Point to a hosted file.
- Upload once, then reference it by file_id across many requests (avoids re-uploading large files).
Here is what an image content block looks like alongside a text question:
# Conceptual: an image content block alongside text (see docs for exact fields)
messages=[{
"role": "user",
"content": [
{"type": "image", "source": {"type": "base64", "media_type": "image/png", "data": b64}},
{"type": "text", "text": "What does this chart show? Give the top 3 takeaways."},
],
}]
PDFs work similarly (a document content block); Claude can read text and visual layout, and you can request citations back to where in the document an answer came from.
What it's great for
- Extraction — pull structured data from invoices, forms, tables (pair with Structured Output: /docs/api/structured-output).
- Understanding visuals — charts, diagrams, screenshots, UI.
- Document Q&A — ask questions across a long PDF with citations.
A quick copy-paste starter for document Q&A:
Document Q&A prompt
What does this chart show? Give the top 3 takeaways.
Tips
- Reuse with file_id when sending the same big document repeatedly — cheaper and faster.
- Resolution/size matter — very large images may be downscaled; check limits.
- Verify extracted numbers — vision is strong but not infallible; spot-check critical figures.
- Vision is strong but not infallible — always spot-check critical figures. See Hallucinations: /docs/foundations/hallucinations.
Check yourself
0/3Next
- Structured Output
- Generating Real Files (docx/pptx/xlsx/pdf)
- Tokens & Pricing — images cost tokens too