# https://compresr.ai/docs/introduction

> Human-readable page: https://compresr.ai/docs/introduction

Compresr is a context-compression API for LLM developers. Send the long text you'd pass to your model with the `query` you want answered; Compresr keeps the spans that carry the answer, drops the rest, and returns a shorter context you forward to your LLM. The result: fewer input tokens, lower cost, a longer effective context window, and faster inference. It sits in front of whatever LLM stack you already use and replaces nothing.

## Use cases

Anywhere you send long text with a question about it:

- **RAG** — compress retrieved chunks before they reach the model, so you only pay for tokens that carry the information.
- **Conversations** — compress growing chat history so long sessions stay inside the context window.
- **Tool outputs (agents)** — compress noisy tool results — web search hits, API responses, file dumps — before they re-enter the prompt. Pass the tool call's intent as the `query` so Compresr keeps only what the agent asked for.
- **Document understanding** — ask a question against long, dense documents — legal contracts, medical records, financial filings — and keep only the spans that answer it.

## The models: `latte_v1` and `latte_v2`

Compresr exposes two query-specific compression models on the public API:

- **`latte_v1`** — the stable, battle-tested model.
- **`latte_v2`** *(beta)* — the newer model: up to 5x faster than `latte_v1` on query-specific compression.

> **Which one to use**
> Reach for `latte_v2` by default. It's a drop-in for `latte_v1`: every parameter `latte_v1` takes works here too, plus a `dynamic` mode that picks the compression ratio per input. `latte_v1` stays available for the rare case where `latte_v2` falls short.

## Parameters

Every call takes a `query` and the `context` to compress. Everything else is optional:

Param names below are Python + cURL (snake_case). TypeScript uses camelCase: `targetCompressionRatio`, `heuristicChunking`, `disablePlaceholders`, `dynamicMinRatio`, `dynamicMaxRatio`.

| Parameter | Type | Required | Description |
| --- | --- | --- | --- |
| `query` | string | yes | The question or instruction Compresr scores against. It keeps the spans of context that carry the information and drops the rest. |
| `target_compression_ratio` | number | no | How aggressively to compress. `0 < r ≤ 1` removes that fraction of the input; `r > 1` targets an `r`x reduction (server caps at 200). Ignored when `dynamic` is on. |
| `coarse` | boolean | no | Score at paragraph granularity instead of token by token. Faster on very long inputs where fine-grained precision is not needed. Omit to get the backend default (paragraph-level). |
| `heuristic_chunking` | boolean | no | Split the input with a heuristic chunker before scoring. Helps on structured inputs like logs, transcripts, and tables. |
| `disable_placeholders` | boolean | no | Return only the kept spans, with no placeholder markers between removed regions. Useful when the downstream LLM is sensitive to gap markers. |
| `dynamic` | boolean | no | `latte_v2` only. Let Compresr choose the compression ratio per input instead of a fixed `target_compression_ratio`. A good default for mixed-difficulty inputs; use a fixed ratio when you need a predictable token budget. |
| `dynamic_min_ratio` | number | no | `latte_v2` only. Lower bound on the ratio `dynamic` can pick. |
| `dynamic_max_ratio` | number | no | `latte_v2` only. Upper bound on the ratio `dynamic` can pick. |

The three `dynamic*` parameters are `latte_v2` only. Full semantics, defaults, and the support matrix live in the [Models reference](/docs/api-reference/models).

## Start with

Pick your language and send the first request. The shape of the call is identical across all three; only the syntax differs.

### Pick a language

- [Python](/docs/sdks/python) - `pip install compresr`, then call `client.compress(...)`. The legacy `compresr[langchain]` and `compresr[agents]` extras still resolve as no-op aliases; the base install already ships every integration.
- [TypeScript](/docs/sdks/typescript) - `npm install @compresr/sdk`, then call `client.compress({...})`.
- [cURL](/docs/sdks/curl) - one `POST` request, no install required.

### Framework integrations

First-party integrations ship in both SDKs, so you can drop them into existing pipelines without rewriting the surrounding code.

- [LangChain](/docs/framework-integration/langchain): three middlewares (tool output, history summarization, prompt budget) + RAG document compressor + single-tool wrapper (HOF or decorator), for `create_agent` and `ContextualCompressionRetriever`.
- [LangGraph](/docs/framework-integration/langgraph): re-exports the three middlewares plus adds `make_compresr_node`, `CompresrCheckpointSerializer`, `CompresrStore`, and `compresr_handoff_tool` for state graphs, at-rest compression, and supervisor → sub-agent transfers.
- [LlamaIndex](/docs/framework-integration/llamaindex): `CompresrNodePostprocessor` for query engines, `wrap_tool_with_compresr` for `FunctionTool`s, and `CompresrMemoryBlock` for the Memory API.
- [LiteLLM](/docs/framework-integration/litellm): Python-only `pre_call` guardrail that auto-compresses tool/function messages before they go upstream, working against every LiteLLM provider.
- [LLM provider recipes](/docs/framework-integration/llm-providers): manual pattern called directly against OpenAI, Anthropic, Gemini, or local Ollama.

### Related reading

- [Quick start](/docs/quick-start) - the same 30-second example in Python, TypeScript, and cURL.
- [Authentication](/docs/authentication) - how `cmp_` keys are issued, rotated, and revoked.
- [API reference](/docs/api-reference/conventions) - every endpoint, parameter, and response field.
