Skip to main content

Claude PDF Support

Claude models support processing PDF documents directly. You can send PDF files via URL or Base64 encoding to let Claude read, analyze, and summarize document content.
POST /v1/messages

Send PDF via URL

curl https://crazyrouter.com/v1/messages \
  -H "Content-Type: application/json" \
  -H "x-api-key: YOUR_API_KEY" \
  -H "anthropic-version: 2023-06-01" \
  -d '{
    "model": "claude-sonnet-4-20250514",
    "max_tokens": 4096,
    "messages": [
      {
        "role": "user",
        "content": [
          {
            "type": "document",
            "source": {
              "type": "url",
              "url": "https://example.com/report.pdf"
            }
          },
          {
            "type": "text",
            "text": "Summarize the main content of this document and list the key points"
          }
        ]
      }
    ]
  }'

Send PDF via Base64

curl https://crazyrouter.com/v1/messages \
  -H "Content-Type: application/json" \
  -H "x-api-key: YOUR_API_KEY" \
  -H "anthropic-version: 2023-06-01" \
  -d '{
    "model": "claude-sonnet-4-20250514",
    "max_tokens": 4096,
    "messages": [
      {
        "role": "user",
        "content": [
          {
            "type": "document",
            "source": {
              "type": "base64",
              "media_type": "application/pdf",
              "data": "JVBERi0xLjQKMSAwIG9iago..."
            }
          },
          {
            "type": "text",
            "text": "What are the main terms of this contract?"
          }
        ]
      }
    ]
  }'

Multi-Document Analysis

You can send multiple PDFs simultaneously for comparative analysis:
Python
message = client.messages.create(
    model="claude-sonnet-4-20250514",
    max_tokens=4096,
    messages=[
        {
            "role": "user",
            "content": [
                {
                    "type": "document",
                    "source": {
                        "type": "url",
                        "url": "https://example.com/report_q1.pdf"
                    }
                },
                {
                    "type": "document",
                    "source": {
                        "type": "url",
                        "url": "https://example.com/report_q2.pdf"
                    }
                },
                {
                    "type": "text",
                    "text": "Compare these two quarterly reports and analyze the trends in key metrics"
                }
            ]
        }
    ]
)

Streaming Processing

PDF analysis also supports streaming output:
Python
with client.messages.stream(
    model="claude-sonnet-4-20250514",
    max_tokens=4096,
    messages=[
        {
            "role": "user",
            "content": [
                {
                    "type": "document",
                    "source": {"type": "url", "url": "https://example.com/paper.pdf"}
                },
                {"type": "text", "text": "Analyze the research methodology and conclusions of this paper in detail"}
            ]
        }
    ]
) as stream:
    for text in stream.text_stream:
        print(text, end="")
Each page of a PDF document consumes tokens. The more pages, the higher the consumption. It is recommended to process large documents in segments or extract key pages.
PDF file size should not exceed 32MB. Oversized files may cause request timeouts.