Compress

Compress request

Compresses an LLM request payload and returns it with the messages, input, system, and tools fields replaced by their compressed versions. Accepts OpenAI Chat Completions, Anthropic Messages, and OpenAI Responses API formats — the wire format is auto-detected from the request body.

No LLM provider is called. This is a pure pre-processing step intended for teams running their own LLM gateways who want Edgee token compression without routing requests through Edgee.

post/v1/compress

Request

  • Base URL: https://edgee.io
  • URL: https://edgee.io/v1/compress
  • Auth: one of:
    • HTTP bearer
    • API key in header x-api-key

Headers

X-Edgee-Compression-Tool-Result-Trimming'true' | 'false' | '1' | '0' | 'on' | 'off'

Tool-result trimming is on by default on this endpoint. Set to false, 0 or off to get the payload back unchanged, without the compression field. Values are case-insensitive, and an invalid value leaves trimming on.

Request body

OR
OR

Example request

{
  "model": "openai/gpt-5.2",
  "messages": [
    {
      "cache_control": {
        "type": "ephemeral"
      }
    }
  ],
  "reasoning_effort": "high"
}

Response

Request compressed successfully. The response mirrors the input format with the messages, input, system, and tools fields replaced by their compressed versions. All other fields pass through unchanged. A compression metadata object is appended when trimming runs. When the tool-result-trimming header disables compression, the original payload is returned without added compression metadata.

Example response

{
  "compression": {
    "technique": "tool",
    "applied_strategies": [
      "tool_result_trimming"
    ],
    "compression_rate": 0.81,
    "uncompressed_input_tokens": 1000,
    "compressed_input_tokens": 810,
    "compression_time_ms": 12
  }
}

Changes

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