Documentation

Compression profiles

How much of your document may go, and how that limit gets decided.

Picking a profile

Three profiles, switchable per call. They differ in how much of your document may go and how that limit is decided — not in speed: measured end-to-end, the three are indistinguishable from each other, and on large documents all of them answer sooner than sending the full text, because the model has less to read. Leave compression_profile unset and you get auto — and if you are not sure what to pick, stay on auto: it adapts per request, so you cannot get it wrong.

ProfileAnswers keptTypical savingsReach for it when
"auto" 159 / 218 2–24% on the strict benchmark; 36–62% on pointed questions over cluttered contexts, up to 98% on truly repetitive text Default. Reads your document instead of asking you about it. How much may go is decided from how repetitive the text is, how densely it carries figures and names, and whether your request reads as "find this" or "list them all" — none of which you should have to estimate yourself. On CVs and rosters it behaves like exact; on a negotiated contract it lands in between. Ties for the smallest change in answers of any profile.
"fast" 157 / 218 8–42% You want the most tokens removed. It works from cheap signals alone, which is what makes it the deepest of the three — and also why it is likelier than auto to drop a fact a long turn was carrying.
"exact" 159 / 218 0–95%, document-dependent Nothing is dropped unless something equivalent stays. Instead of removing a set share of the text, it keeps going until every passage has a close-enough stand-in among those kept — so a document of repeated boilerplate collapses to a few percent, and a document where every line is a distinct fact comes through untouched. Reach for it when the request is "list every…": CVs, invoices, rosters, audit findings.
resp = client.chat.completions.create(
    model="gpt-4o-mini",
    messages=[{"role": "user", "content": question}],
    extra_body={"compression_profile": "exact"},
)

Does compression change the answer?

This is the only question that matters, so it is measured directly rather than inferred from how much text survived. 218 cases from public datasets where a single wrong answer counts as a failure — exact contract spans (CUAD), negation-heavy NDA entailment (ContractNLI), biomedical decisions (PubMedQA), multi-hop questions (HotpotQA distractor), exhaustive "find every id" retrieval, code-file location (SWE-bench) and a real production log. Same document, same question, same model, temperature 0.

CategoryCasesNo compressionautofastexact
Contract span, exact quote4130282828
NDA entailment (negation)4035363436
Biomedical decision6038383838
Multi-hop question4025252525
Exhaustive "every id"2020202020
Code file location128888
Production log54444
Answered correctly218160159157159

One answer out of 218 separates the default from sending the whole document, and the 95% interval on that difference runs from −3.2 to +2.2 percentage points — it is noise, not a cost. Four of the seven categories came out identical under every profile, including the exhaustive "return all of them" set, where all 20 cases passed everywhere. On negation, auto and exact each answered one case that the uncompressed document got wrong. Compression is buying you tokens, not costing you answers — and where a document genuinely cannot be compressed safely, the profiles that know it say so by compressing less.

Summarisation is where compression pays most. On query-focused meeting summaries auto removed 72% of the prompt — more than on any other workload, because a transcript repeats itself in a way a contract does not.

The honest caveat. Summaries are the one place we can measure a difference rather than noise. Scored as overlap with a reference summary on 12 cases, answers written from a compressed transcript came out at 0.22 against 0.29 from the full one. That is not facts vanishing — summarising drops detail by definition, and the uncompressed baseline drops it too; the comparison is like-for-like, and what moved is breadth, on a crude word-overlap score over a small sample. If a summary needs to mention everything rather than the main threads, send it through a -raw alias and compare on your own material.

And one on exact. Its savings depend entirely on how repetitive your document is — on public legal and biomedical benchmarks, where almost every paragraph says something different, it saves only a few percent, because there is genuinely nothing safe to drop.

What to expect from your own documents

Savings are not a property of the service — they are a property of your text. Repetition is what can be removed; a document where every line says something new has nothing safe to give up. Measured on real documents. The middle column is the deepest setting we have ever run, so read it as a ceiling — fast lands below it and auto below that:

Your documentBudget ceilingexactWhat happens
Boilerplate-heavy contract, repeated clauses ~50% ~97% Near-identical clauses collapse into one; the clause that answers you stays.
Server logs, uniform lines ~55% ~95% Routine lines are interchangeable; the error line is not, and it survives.
Negotiated contract, every clause distinct ~39% ~16% Distinct clauses mean less can safely go; what the question names always stays.
CV, invoice, roster — a list of facts ~45% ~2% exact barely compresses here — on purpose, because every line is its own fact and nothing is safe to remove.

If you are extracting records — every position, every line item, every finding — use exact and expect little compression. That is the honest outcome, and it is cheaper than re-running a job that silently lost half its rows.

Your prompt matters more than the profile

Compression scores every passage against what it believes you are asking. A precise question makes that judgement easy and a vague one makes it guesswork, so the same document can compress well or badly depending on how you ask. Three habits pay for themselves:

Ask for the thing you want. "What is the termination notice period?" tells us which passages carry the answer. "Summarise this" tells us nothing — every passage looks equally relevant, and you get less savings, not worse answers.

Put the document in context, not in the question. Then your question is scored on its own instead of being guessed at from a wall of text. This is the single biggest accuracy win available to you — see section 4.

Name the identifiers you care about. If the answer hinges on order 88317 or clause 14.2, put it in the question. Anything your question names is pinned and cannot be dropped.

# Weaker: the question is buried and unspecific
client.chat.completions.create(
    model="gpt-4o-mini",
    messages=[{"role": "user", "content": long_contract + "\n\nThoughts?"}],
)

# Better: separate document from question, and be specific
client.chat.completions.create(
    model="gpt-4o-mini",
    messages=[{"role": "user",
               "content": "What is the termination notice period in clause 14.2?"}],
    extra_body={"context": long_contract, "compression_profile": "exact"},
)

If a document is mostly unique facts — a log where every line has its own id — there is little any profile is allowed to drop, and savings will be modest whatever you pick. That is the compressor refusing to guess, and it is the behaviour you want.

Compressing output tokens

Output tokens often cost more than input. Set compress_output to true when you want fewer completion tokens on that request while keeping answer quality. It works with any model you call through CompresLM (the numbers on the home page are examples from tests, not a limited model list). Set it to false (or omit it) for the default behavior (input compression only).

Body fieldTypeDefaultMeaning
compress_output boolean false true — enable output-token savings on this request. false — input compression only.
resp = client.chat.completions.create(
    model="gpt-4o",
    messages=[{"role": "user", "content": "Which store is cheaper after tax?"}],
    extra_body={
        "context": long_document,
        "compress_output": True,  # opt-in output savings
    },
)
curl https://compreslm.com/v1/chat/completions \
  -H "Authorization: Bearer YOUR_COMPRESLM_TOKEN" \
  -H "X-LLM-API-Key: YOUR_PROVIDER_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "gpt-4o",
    "compress_output": true,
    "context": "...long document...",
    "messages": [{"role":"user","content":"What fee is owed, and when does termination take effect?"}]
  }'

On controlled paired tests (same cases, same gold answers), enabling output compression kept 100% answer accuracy while cutting mean completion tokens by about 60% on GPT-4o, 68% on Claude Sonnet, and 26% on o3-mini versus a verbose baseline — example models only; the same flag applies to other models you route through CompresLM. See the charts on the home page.

Billing: input compression alone is billed at 20% of measured dollar savings on the input. When compress_output is true, our fee is 50% of those same input-token dollar savings (the fee base stays input savings — so the amount is always computable). Your dashboard also shows output tokens saved for those calls (scaled from observed completions using ~60% average reduction) — that display number is not used for fees. Details: How billing works · output savings on the dashboard.