Claude's context windows are large — 1M tokens on current Opus, Sonnet, and Fable models, 200K on Haiku 4.5 — but enterprise documents are larger than they look. A dense PDF costs roughly 1,500–3,000 text tokens per page plus image tokens, because each page is converted to an image alongside its extracted text. A few hundred pages of scanned-and-mixed material can crowd a window long before you hit the 600-page-per-request PDF limit. So long-document prompting is really two skills: placing documents well when they fit, and degrading gracefully when they don't.
Placement: document first, question last
Anthropic's official guidance for long-context prompting (roughly 20k input tokens and up) is unambiguous: put the longform data at the top of the prompt, above your instructions, examples, and query. Placing the query at the end can improve response quality by up to 30% in Anthropic's testing. The same ordering rule applies to images and PDFs — content before text.
When you're sending several documents, wrap each in its own <document> tag with <document_content> and <source> subtags, so Claude can tell them apart and reference them by name. Structure is cheap insurance against the model blending two contracts into one answer.
from anthropic import AnthropicVertex
client = AnthropicVertex(project_id="my-project", region="global")
prompt = f"""<documents>
<document><source>msa-2026.txt</source>
<document_content>{contract_text}</document_content></document>
</documents>
Which sections govern early termination? Quote them."""
msg = client.messages.create(
model="claude-opus-4-8",
max_tokens=2048,
messages=[{"role": "user", "content": prompt}],
)
When it fits but you'll ask twice: cache it
If a team will interrogate the same document repeatedly — due-diligence review, contract Q&A — mark the document block with cache_control. Cache reads bill at 0.1x the base input price, so the second and every later question against a cached document costs a tenth as much for that portion, and the 5-minute-TTL cache pays for itself by the second request. This is usually a far better lever than aggressive summarization, because the model keeps seeing the full text.
When it doesn't fit: the summarization ladder
Past the window (or past your latency budget), fall back to a ladder of progressively lossy strategies. Climb only as high as you must:
| Rung | Strategy | What you lose |
|---|---|---|
| 1 | Split by natural boundaries (sections, exhibits) and query the relevant chunk | Cross-section reasoning |
| 2 | Map-reduce: summarize each chunk, then answer from the stitched summaries | Verbatim detail; quotes need a second pass |
| 3 | Retrieval: index chunks, pull only passages relevant to the question | Anything the retriever misses |
Chunk on meaning, not byte counts — a clause split mid-sentence is worse than a slightly oversized chunk. And keep an audit trail: when the answer comes from summaries of summaries, downstream readers should know they're two steps from the source. For extraction-style questions where a citation matters, run rung 2 to locate the relevant section, then re-ask against the original text of just that section.
count_tokens endpoint accepts the same inputs as a real request — including PDFs — and tells you whether the document actually fits. Note that current models (Opus 4.7+, Sonnet 5, Fable 5) tokenize the same text into roughly 30% more tokens than earlier generations, so recount against the model you'll actually call.Long conversations are long documents too
Multi-turn workflows over big documents hit the same wall from the other direction: the conversation itself outgrows the window. The API now offers server-side compaction (beta) — near the limit it summarizes older turns into a compaction block, and content before that block is dropped automatically on the next request. Default trigger is 150,000 input tokens. For agentic workloads there is also context editing, which clears old tool results server-side. Both beat hand-rolled truncation, which tends to silently delete the one paragraph the user asks about next.
Platform notes
PDF processing works on all four third-party platforms, but Amazon Bedrock and Google Vertex AI accept base64-uploaded PDFs only — no URL references, and no Files API to park a large document once and reference it by ID. On the Claude API and Claude Platform on AWS, the Files API (beta) lets you upload up to 500 MB per file and reference it across requests, which pairs naturally with repeated long-document analysis. One Bedrock-specific quirk: on the legacy Converse surface, full visual PDF understanding requires citations to be enabled; without them it falls back to text-only extraction.
Where to go next
Placement is half the battle; the other half is grounding — see grounding prompts for RAG applications and summarization prompt patterns. For where these features run, check the feature matrix.