compression

Compress a text input

Compresses a single input — a string, or an object or array that is JSON-encoded first — and returns the compressed text with before-and-after token counts. Send the result to any LLM in place of the original. Wrap any span in <ttc_safe> tags to exclude it from compression. Aggressiveness guidance: 0.05-0.2 for text the model must answer questions about, 0.5-0.8 for conversation history and background context. If the compression backend is unavailable the API returns the original input unchanged rather than failing, so a compression outage never breaks the calling flow.

post/v1/compress

Request

Request body

modelstring required

Compression model. bear-2 is current and recommended; bear-1.2 is the previous generation.

app_idstring

Your own label for the calling application, so usage can be broken down per app. A per-request value overrides one set on the client.

Example request

{
  "model": "bear-2"
}

Response

The compressed text and its token counts.

outputstring required

The compressed text, ready to send to any LLM.

output_tokensinteger required

Token count after compression.

original_input_tokensinteger required

Token count of the original input, before compression.

Changes

No recorded changes to this operation across all 1 revision of this API.