# Claude long context and PDF: 1M context, document and file content blocks Source: https://ofox.ai/docs/develop/models/claude/pdf This page covers Claude's context length and how to send PDF input. For model IDs and endpoints, see the [Claude family overview](https://ofox.ai/docs/develop/models/claude). ## 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](https://ofox.ai/docs/develop/models/claude#errors). ## PDF input **Anthropic-native API** ```python filename="claude_pdf.py" import base64 import os import anthropic client = anthropic.Anthropic(base_url="https://api.ofox.ai/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) ``` **OpenAI-compatible API** ```python filename="claude_pdf_openai.py" import base64 import os from openai import OpenAI client = OpenAI(base_url="https://api.ofox.ai/v1", api_key=os.environ["OFOX_API_KEY"]) pdf_b64 = base64.b64encode(open("invoice.pdf", "rb").read()).decode() resp = client.chat.completions.create( model="anthropic/claude-haiku-4.5", max_tokens=1024, messages=[{"role": "user", "content": [ {"type": "file", "file": {"filename": "invoice.pdf", "file_data": f"data:application/pdf;base64,{pdf_b64}"}}, {"type": "text", "text": "What is the total amount on this invoice?"}, ]}], ) print(resp.choices[0].message.content) ``` 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](https://ofox.ai/docs/develop/models/claude#errors).