Skip to main content
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

Supported document.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": ... }
Use this when the document is already hosted and reachable by URL.
{
  "type": "url",
  "url": "https://example.com/report.pdf"
}

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
If you are starting fresh, compare this with Responses Multimodal Inputs.

PDF URL Example

from anthropic import Anthropic

client = Anthropic(
    base_url="https://api.naga.ac",
    api_key="YOUR_API_KEY",
)

message = client.messages.create(
    model="claude-sonnet-4.5",
    max_tokens=256,
    messages=[
        {
            "role": "user",
            "content": [
                {
                    "type": "document",
                    "title": "Quarterly Report",
                    "source": {
                        "type": "url",
                        "url": "https://example.com/report.pdf",
                    },
                },
                {
                    "type": "text",
                    "text": "What are the key findings in this document?",
                },
            ],
        }
    ],
)

print(message.content)

Content-Source Example

The compatibility layer also accepts content-source documents.
{
  "role": "user",
  "content": [
    {
      "type": "document",
      "title": "Spec",
      "source": {
        "type": "content",
        "content": [
          {
            "type": "text",
            "text": "Inside doc"
          }
        ]
      }
    }
  ]
}

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