Messages API accepts Anthropic-style document blocks for PDFs and text-like document content.
Use this when your existing Anthropic-style client already works with document blocks and you want to keep that format.
Document Source Types
Supporteddocument.source variants on this surface are:
{"type":"url","url":"https://..."}{"type":"base64","media_type":"application/pdf","data":"..."}{"type":"text","media_type":"text/plain","data":"..."}{"type":"content","content": ... }
- URL
- Base64
- Text
- Content
Use this when the document is already hosted and reachable by URL.
When to use this surface
- you already depend on Messages document semantics
- your app needs PDFs or other document-like content inside an Anthropic-style conversation
PDF URL Example
Content-Source Example
The compatibility layer also acceptscontent-source documents.
Caveats
- document support still depends on the selected model
- large PDFs increase token usage after provider-side parsing
- use this API only when you specifically need Anthropic-compatible document semantics
Common mistakes
- assuming every model that supports text also supports document blocks
- sending very large documents without expecting higher token cost
- mixing Messages document syntax with Chat Completions or Responses file syntax