Documentation
API reference
Endpoints, headers and the body fields we add.
Get the composed prompt back, with no model call
Building a gateway, a router, or your own orchestration?
POST /v1/compress takes your text and question and
returns the composed prompt as a string. Nothing is forwarded, no model is
called, no provider key is involved — what you do with the result is
entirely yours.
Use it to compress once and reuse the result across several calls, to send the output to a provider we do not sit in front of, to cache it, to count tokens before deciding which model to route to, or simply to read what survived before trusting the pipeline with production traffic.
Only your CompresLM token is needed — no provider key, because no completion happens. Usage counts toward the same free tier and billing as proxied requests, measured on the tokens we actually saved you.
curl https://compreslm.com/v1/compress \
-H "Authorization: Bearer YOUR_COMPRESLM_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"text": "...the long document...",
"query": "What is the termination notice period?",
"compression_profile": "auto"
}'
Response:
{
"ok": true,
"compressed_text": "...only the passages that answer the query...",
"compressed": true,
"stats": { "orig_tokens": 4393, "new_tokens": 2096, "tokens_saved": 2297, ... }
}
query is required and does the same job as your
question does on the chat endpoint: it decides what survives. Compressing
against a query that does not match how you will later use the text is the
one way to lose something you needed.
API reference
Everything on one screen.
Endpoints
| Endpoint | Needs | Returns |
|---|---|---|
| POST /v1/chat/completions | CompresLM token + provider key | A normal chat completion, from a shorter prompt. |
| POST /v1/compress | CompresLM token only | The composed prompt as a string, for you to use however you like — the endpoint to build a gateway or router on. No model is called. |
| GET /v1/models | CompresLM token | The named aliases. Any other model name works too — it is not a menu. |
Headers
| Header | Required | Meaning |
|---|---|---|
| Authorization: Bearer … | Required | Your CompresLM token. Identifies the account. |
| X-LLM-API-Key | Required for completions | Your provider key. Used for this one call, never stored. Not needed by /v1/compress — nothing is called. |
| X-LLM-API-Base | Optional | Your own inference server (vLLM, Ollama). Prefix the model name with the API flavour it speaks, e.g. openai/my-model. |
Body fields we add
All optional; everything else is standard OpenAI. Unknown values fall back to the default rather than failing the call.
| Field | Values | Effect |
|---|---|---|
| context | string | Your document. Scored against the user message as the question — the most accurate way to call us (what to send where). |
| compression_profile | "auto" · "fast" · "exact" | How much of your document may go, and how that limit is decided (profiles). Default auto. |
| compress_output | boolean | Also shorten the answer, not just the prompt (profiles). Default false. |
Turning compression off
Append -raw to a named alias (gpt-4o-mini-raw, gpt-4o-raw, claude-sonnet-raw). The fields above are still accepted and ignored, so the same request body works against both and you can A/B a compressed call against an uncompressed one.
Everything else
CompresLM is OpenAI-compatible: streaming, tool calls, JSON mode and the rest pass through untouched. Anything your OpenAI or Anthropic SDK does today works here — this page is the reference, and the endpoint table above is the whole surface you need.
Need on-prem or a custom compression profile? Contact us — we help set it up for free.