AI Document Summarization APIs: Long Docs Without the Token Burn
Summarizing long documents with LLM APIs: map-reduce over chunks, choosing map and reduce models, cost control, and quality checks that catch bad summaries.
Summarizing documents with LLM APIs is one of the most requested features in the stack — and one of the easiest ways to burn money. A 200-page PDF is millions of tokens, and feeding it whole to a single call is both expensive and shallow. The craft is chunking, map-reduce, and quality control, done in a way that scales to your corpus.
Why the single-call approach fails
A single call with a giant prompt produces a thin summary: the model sees everything at once, so it flattens detail into a generic overview. Long contexts also cost the most per token and hit latency limits that feel broken in a UI. The fix is to summarize hierarchically: split the document, summarize the parts, then summarize the summaries.
Map-reduce in practice
- Split the document into sections with stable boundaries.
- Summarize each section with the same instructions — the map step.
- Collect the section summaries, preserving order and headings.
- Summarize the combined summaries into the final document — the reduce step.
- For very large outputs, add another level: summaries of summaries.
Chunking for summaries, not retrieval
Chunking for summarization differs from chunking for retrieval. Here each chunk should be a coherent unit — a chapter, a section, a page — so the map step produces self-contained mini-summaries. Keep headings attached to their text so the reduce step can reason about structure. Overlap matters less than boundaries: splitting mid-table or mid-list destroys meaning that no summary step can recover.
Controlling cost at scale
- Summarize at the resolution the reader needs: one line, one paragraph, one page.
- Use a cheaper fast model for the map step and a stronger model for the final reduce.
- Cache summaries per document version and reuse them.
- Estimate tokens before the run and warn on outliers.
- Use batch APIs for offline corpora where nothing is waiting.
Quality checks that catch bad summaries
Summaries fail silently. Add checks: does the summary contain the key numbers and named entities from the source? Do the section headings survive? Is anything contradicted? Run an LLM judge that compares the summary against the source for coverage and faithfulness, and spot-check a sample by hand. Log the checks alongside each summary so regressions are visible when you change models or prompts.
Define the output contract first
Decide the output shape before generating: length, heading structure, bullet density, and whether to cite source sections. Structured summaries — sections and bullet lists — are more useful and easier to verify than prose, and they play nicely with downstream systems that render or further process the result.
FAQ
How do I summarize a very long document with an LLM API?+
Use a map-reduce approach: split into coherent sections, summarize each, then summarize the summaries. One call over the whole document is expensive and produces a shallow result.
How much does document summarization cost?+
It scales with tokens read and generated. Mapping with a cheap model, reducing with a stronger one, and caching per document version keeps large-corpus costs manageable.
How do I know a summary is accurate?+
Check coverage of key entities and numbers, verify there are no contradictions against the source, and use an LLM judge plus human spot-checks on a sample.
Related posts
Aug 12, 2026 · Prompt engineering
Context Window Optimization: Using Every Token WiselyContext window optimization: pack more useful information, trim noise, and use context efficiently to improve answers and cut token costs.
Aug 15, 2026 · Prompt engineering
LLM Context Compression: Fitting More Into LessLLM context compression techniques: summarization, retrieval, and token-efficient prompting to fit long histories into small context windows.
Aug 16, 2026 · Cost control
LLM API Pricing Comparison 2026: Costs Side by SideLLM API pricing compared in 2026: input/output rates, caching, batch discounts, and how to model total cost across OpenAI, Anthropic, Google, and more.