← Blog

Claude API Long Document Summarization: Chunking Guide

2026-11-11 · 5 min read · SubToAPI Team

Why Chunking Matters for Long Document Summarization

When you send a document to the Claude API for summarization, you're constrained by two things: the model's context window and the quality of summary you get back. Claude 3.5 and 3.7 models support context windows up to 200K tokens, which handles most PDFs, contracts, and reports in a single call. But once a document exceeds that limit — or when you need a dense, structured summary rather than a diluted one — you need to split the text into chunks, summarize each piece, and then combine those partial summaries into a final output. This process is called chunking, and it's the standard approach for summarizing books, legal filings, codebases, research corpora, or any text that won't fit (or doesn't summarize well) in one pass.

The short answer: split your document into overlapping chunks of 3,000–8,000 tokens, summarize each chunk independently with a consistent prompt, then run a second "reduce" pass that combines those chunk summaries into one coherent final summary. This is known as the map-reduce pattern, and it works reliably even on documents with hundreds of thousands of words. Below is a practical breakdown of how to size chunks, where to split them, and how to structure the API calls.

When You Actually Need Chunking

Before building a chunking pipeline, check whether you need one. If your document fits comfortably under 150K tokens (roughly 110,000 words), a single call to Claude with a clear summarization prompt often outperforms chunking, because the model can reason across the whole text at once instead of losing cross-section context. Chunking is a tool for scale and structure, not a default.

You need chunking when:

How to Split the Document

The split strategy matters more than the exact chunk size. Three approaches, in order of preference:

1. Structural splitting. Split on headings, chapter breaks, markdown sections, or page boundaries. This preserves semantic coherence inside each chunk and makes the reduce step easier because chunk summaries already align with the document's logical structure.

2. Token-based splitting with overlap. When there's no clean structure, split by token count (not characters — token count determines cost and context usage) and add 10–15% overlap between chunks so sentences aren't cut mid-thought and context isn't lost at boundaries.

3. Sentence-boundary splitting. Never split mid-sentence. Use a tokenizer-aware splitter that snaps to the nearest sentence end, even if it means chunks vary slightly in size.

A reasonable default: 4,000-token chunks with a 400-token overlap. This keeps each chunk small enough for a fast, cheap summarization call while giving the model enough context to produce something useful.

function chunkText(text, maxTokens = 4000, overlapTokens = 400) {
  const words = text.split(/\s+/);
  const wordsPerToken = 0.75; // rough estimate
  const chunkWords = Math.floor(maxTokens * wordsPerToken);
  const overlapWords = Math.floor(overlapTokens * wordsPerToken);

  const chunks = [];
  let start = 0;
  while (start < words.length) {
    const end = Math.min(start + chunkWords, words.length);
    chunks.push(words.slice(start, end).join(' '));
    start += chunkWords - overlapWords;
  }
  return chunks;
}

Use a real tokenizer in production instead of a word-count heuristic — this is just for illustration.

The Map-Reduce Summarization Pattern

Map step: send each chunk to Claude with a consistent, narrow prompt. Ask for a structured summary (bullet points, key entities, decisions, numbers) rather than freeform prose — structured output is easier to merge later.

Summarize the following text excerpt in 5-8 bullet points.
Focus on facts, decisions, and numbers. Do not add commentary
outside the text's content.

Text:
{{chunk}}

Reduce step: once you have all chunk summaries, concatenate them and send a second request asking Claude to synthesize them into one coherent summary, removing redundancy and resolving references across chunks.

Below are summaries of sequential sections of a single document.
Combine them into one coherent summary of the full document,
removing duplicate points and preserving chronological order.

{{all_chunk_summaries}}

For very large documents (dozens of chunks), you may need a hierarchical reduce: summarize groups of chunk-summaries first, then summarize those group summaries into a final one. This keeps each reduce call within a manageable token budget and avoids the reduce step itself becoming a long-document problem.

Running This Through SubToAPI

If you're building this pipeline as part of a product rather than a one-off script, the operational concerns — API keys, rate limiting across concurrent chunk calls, usage tracking per customer — become the harder part. SubToAPI turns your existing Claude access into a standard HTTPS API with sub_live_ application keys, so each chunking job can run under its own key with its own usage metadata, which is useful when you're billing customers per document or tracking cost per summarization job.

A map step chunk call looks like this against SubToAPI's messages endpoint:

curl https://api.subtoapi.app/v1/messages \
  -H "Authorization: Bearer $SUBTOAPI_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "claude-3-5-sonnet-20241022",
    "max_tokens": 500,
    "messages": [
      {"role": "user", "content": "Summarize this excerpt in 5-8 bullet points: ..."}
    ]
  }'

Because the map step typically means firing off many chunk requests, streaming isn't usually necessary at that stage — see /docs/streaming if you want to stream the final reduce response back to a UI instead. Full request/response details are in /docs/messages, and /docs/quickstart covers generating your first API key. Teams running this at volume typically land on the Team or Scale plans — see /pricing for seat pricing.

Practical Tips

Questions

Does Claude's 200K context window mean I never need chunking? No. It covers most single documents, but chunking is still useful for documents that exceed it, for structured section-by-section summaries, or for parallelizing summarization across many documents at once.

How much overlap should I use between chunks? 10–15% of the chunk size is a good default. It's enough to preserve context across a split sentence or idea without meaningfully increasing cost.

Should I use the same model for map and reduce steps? Usually yes, for consistency in tone and structure. Some pipelines use a smaller/cheaper model for the map step and a stronger model for the final reduce, since the reduce step requires better synthesis across more material.

Turn your Claude access into an HTTPS API

SubToAPI gives you application API keys, streaming, tool use and usage insights on top of your existing Claude access — set up in minutes.

Start free  Read the quickstart →