Skip to Content
ModelsClaudeLong context & PDF

Claude long context and PDF

This page covers Claude’s context length and how to send PDF input. For model IDs and endpoints, see the Claude family overview.

1M context

Except for Haiku 4.5 (200K), all models have a 1M-token context, and you do not need to pass the official 1M-context beta header. Exceeding the model’s context returns prompt is too long — see Common errors.

PDF input

claude_pdf.py
import base64 import os import anthropic client = anthropic.Anthropic(base_url="https://api.ofox.io/anthropic", api_key=os.environ["OFOX_API_KEY"]) pdf_b64 = base64.b64encode(open("invoice.pdf", "rb").read()).decode() message = client.messages.create( model="anthropic/claude-haiku-4.5", max_tokens=1024, messages=[{"role": "user", "content": [ {"type": "document", "source": {"type": "base64", "media_type": "application/pdf", "data": pdf_b64}}, {"type": "text", "text": "What is the total amount on this invoice?"}, ]}], ) print(message.content[0].text)

Each PDF page counts toward input tokens as both text and a page image, so watch the context length and cost for long documents.

For other errors, see Common errors.

Last updated on