Skip to main content
POST
Compress

Overview

The /compress/raw/ endpoint compresses your prompt and context, reducing token count while maintaining the semantic integrity needed for high-quality AI responses. Compression ratios of 50–70% are typical, with no meaningful degradation in downstream model output quality.

Request

string
required
Background information, instructions, or supporting text that provides context for the prompt. This is the content most aggressively compressed - structure and meaning are preserved, but redundancy is removed.
string
required
The main query or question to send to your AI model. Kept intact where possible to preserve intent.
object
required
Compression configuration.

Response

The compression result is nested under results; request-level totals and status are at the top level.
object
string
Tokenizer/model name used to count tokens.
number
Input tokens billed for the request.
number
Sum of original tokens across all pairs processed.
number
Sum of compressed tokens across all pairs processed.
number
Number of context/prompt pairs in the request. num_successful and num_failed break this down.
boolean
Whether every pair was compressed successfully. partially_successful is true if only some were.
number
End-to-end request latency in milliseconds.
object

Error responses

Authentication

Include your API key in every request using the x-api-key header.

Examples

Auto compression

Response:

Fixed compression rate

Pass a number for rate when you want a fixed level of compression. rate is the fraction of tokens to remove, so higher values compress more: 0.4 removes about 40% and keeps about 60%. The result is approximate, not an exact token budget.

Notes

  • "auto" rate is recommended for most use cases. Fixed rates below 0.3 may noticeably affect output quality on dense technical content.
  • The compressed_prompt field is a single string - pass it as the full prompt to your downstream model, replacing both context and prompt.

Authorizations

x-api-key
string
header
required

Body

application/json
context
string
required

Background information, instructions, or supporting text that provides context for the prompt.

prompt
string
required

The main query or question to send to your AI model.

scaledown
object
required

Response

Successful compression

results
object
model_used
string
input_tokens
number
total_original_tokens
number
total_compressed_tokens
number
num_pairs_processed
number
num_successful
number
num_failed
number
successful
boolean
partially_successful
boolean
latency_ms
number
request_metadata
object