Compress
Compress a request payload without calling any LLM provider
Compresses an LLM request payload and returns it with the messages, input, system, and tools fields replaced by their compressed versions. No LLM call is made — this is a pure pre-processing step.
Intended for teams running their own LLM gateways (Oracle, Vercel, Cloudflare) who want Edgee token compression without routing requests through Edgee.
To select Anthropic Messages parsing, include a top-level system field (an empty string is sufficient). Otherwise, a payload with input uses Responses parsing, and other payloads use Chat Completions parsing.
The returned compression.compression_rate is the fraction of tokens remaining: 0.81 means 19% saved. These are local tokenizer counts, not provider billing measurements.
Tool-result trimming is enabled by default on this endpoint. Set x-edgee-compression-tool-result-trimming: false to return the original payload without added compression metadata. 0 and off also disable trimming; values are case-insensitive. An omitted or invalid value leaves trimming enabled.
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.
https://edgee.io/v1/compressTry this endpoint
Configure your request, then run the curl command in your terminal or send it from this page.
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.
Run in your terminal
Set EDGEE_API_KEY to your Gateway API key in your terminal, then copy and run this command. Gateway requests may consume credits.
curl --include --no-buffer --globoff --request POST 'https://edgee.io/v1/compress' \
--header "Authorization: Bearer $EDGEE_API_KEY" \
--header 'Content-Type: application/json' \
--data-raw '{
"model": "openai/gpt-5.2",
"messages": [
{
"role": "user",
"content": "Hello!"
}
]
}'Send from browser
Your request is relayed through the Edgee documentation server to the Gateway. Your key is used only for this request and is not stored.
Authentication
Use an Edgee Gateway API key. Send it as Authorization: Bearer <key> or x-api-key: <key>.
Parameters
X-Edgee-Compression-Tool-Result-Trimmingheader · stringTool-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
An LLM request payload to compress. Accepts any of three wire formats — the format is auto-detected from the request body: a top-level `"system"` key indicates Anthropic Messages format; a top-level `"input"` key indicates OpenAI Responses API format; otherwise, OpenAI Chat Completions format is assumed. Include a top-level system field (even an empty string) to select Anthropic parsing when compressing a Messages payload. Format conversion can normalize message/tool content; other top-level fields are retained.
Native dispatch preserves provider-specific JSON fields when the destination supports the caller’s format. Cross-format routing converts through the Gateway’s shared representation: provider-only features are not guaranteed to survive. Support for reasoning, images, built-in tools and structured outputs depends on the destination model.
modelstringrequiredModel identifier from GET /v1/models, in author/model format, or a configured global alias. Append :provider to request a specific provider route. Available models and providers depend on your key and organization policies.
messagesarrayrequiredA list of messages comprising the conversation so far. The shared typed converter also accepts input as an alias, but messages is the portable Chat Completions field for native providers.
Show schema
rolestringrequiredThe role of the message author. Required properties vary by role: - `system`, `user`, `developer`: requires `content` - `assistant`: `content` is optional (can be empty if `tool_calls` is present) - `tool`: requires `content` and `tool_call_id`
contentunionText or multimodal parts. Required for system, developer, user and tool turns; nullable/optional for assistant tool calls.
Show schema
stringtypestringrequiredtextstringrequiredcache_controlobjecttypestringrequiredimage_urlobjectrequiredtypestringrequiredimage_urlstringrequireddetailstringtypestringrequiredsourceunionrequiredProvider-native content such as audio; not guaranteed to survive cross-format conversion.
objectnamestringAn optional name for the participant. Provides the model information to differentiate between participants of the same role. Used for `system`, `user`, `assistant`, and `developer` roles.
tool_call_idstringRequired for tool messages; matches an assistant tool call ID.
refusalstringThe refusal message from the model, if any. Used for `assistant` role only.
tool_callsarrayThe tool calls made by the assistant. Used for `assistant` role only.
Show schema
idstringrequiredThe ID of the tool call.
typestringrequiredThe type of the tool call.
functionobjectrequiredShow schema
namestringrequiredThe name of the function to call.
argumentsstringrequiredThe arguments to call the function with, as JSON.
extra_contentobjectShow schema
googleobjectcache_controlobjectAnthropic cache breakpoint metadata when translating supported system, user or tool content. Cache behavior depends on the destination provider.
reasoning_contentstringReasoning text from the provider, when exposed by the requested reasoning policy.
max_tokensintegerThe maximum number of tokens that can be generated in the chat completion.
streambooleanIf set, partial message deltas will be sent, as in OpenAI. Streamed chunks are sent as Server-Sent Events (SSE).
stream_optionsobjectOptions for streaming response.
Show schema
include_usagebooleanRequest usage in the final usage chunk before the [DONE] sentinel. It does not add a second [DONE] event.
toolsarrayFunction tools and provider-specific tools. Native paths preserve provider tool types; cross-format conversion supports only representable tool semantics.
Show schema
Standard function tool. Provider-native tool objects are also accepted by native Chat-compatible dispatch.
typestringrequiredDiscriminator for the standard function tool variant.
functionobjectrequiredShow schema
namestringrequiredThe name of the function to be called. Must be a-z, A-Z, 0-9, or contain underscores and dashes, with a maximum length of 64.
descriptionstringA description of what the function does, used by the model to choose when and how to call the function.
parametersobjectThe parameters the functions accepts, described as a JSON Schema object. See the guide for examples, and the JSON Schema reference for documentation about the format.
tool_choiceunionTool selection. required/any request tool use; support for none and forced functions depends on provider and conversion path.
Show schema
none declines tools; auto lets the model choose; required/any requests tool use. Provider support varies.
none | auto | required | anystringObject form of a tool selection mode.
typestringrequiredtypestringrequiredThe type of the tool.
functionobjectrequiredShow schema
namestringrequiredThe name of the function to call.
tagsarrayOptional tags to categorize and label the request. Useful for filtering and grouping requests in analytics and logs. Can also be sent via the `x-edgee-tags` header as a comma-separated string.
Show schema
stringenable_debugbooleanEnable request debug capture. Gateway-only field; does not add debug information to the response.
max_completion_tokensintegerAlias of max_tokens. Use one spelling, not both.
temperaturenumberSampling temperature; supported range depends on the destination model.
top_pnumberNucleus sampling probability; support depends on the destination model.
reasoning_effortstringRequested effort; common values include none, minimal, low, medium, high, xhigh and max. The supported vocabulary is model-specific. Cross-format routing maps supported values and can omit unrepresentable levels.
reasoning_summarystringGateway reasoning-display override. Common values: auto, concise, detailed. For Chat Completions, positive reasoning effort normally exposes reasoning_content unless overridden.
reasoning_enabledbooleanGateway override for reasoning intent on cross-format requests; false explicitly declines reasoning.
reasoning_budget_tokensintegerLegacy Anthropic thinking budget, used only when translating to a compatible destination.
Native dispatch preserves provider-specific JSON fields when the destination supports the caller’s format. Cross-format routing converts through the Gateway’s shared representation: provider-only features are not guaranteed to survive. Support for reasoning, images, built-in tools and structured outputs depends on the destination model.
modelstringrequiredModel identifier from GET /v1/models, in author/model format, or a configured global alias. Append :provider to request a specific provider route. Available models and providers depend on your key and organization policies.
max_tokensintegerrequiredMaximum number of tokens to generate
messagesarrayrequiredArray of message objects
Show schema
rolestringrequiredThe role of the message
contentunionrequiredShow schema
Simple text content
stringArray of content blocks
Common Anthropic content blocks. Native dispatch can carry additional provider-specific blocks; conversion paths only preserve supported content. Cross-provider reasoning is emitted as text, never as forged signed thinking blocks.
typestringrequiredtextstringrequiredcache_controlobjecttypestringrequiredidstringrequirednamestringrequiredinputobjectrequiredtypestringrequiredtool_use_idstringrequiredcontentunionrequiredis_errorbooleancache_controlobjecttypestringrequiredsourceunionrequiredcache_controlobjecttypestringrequiredthinkingstringrequiredsignaturestringPreserve provider-issued signatures when replaying history. Unsigned thinking blocks are stripped before upstream Anthropic calls.
typestringrequireddatastringrequiredsystemunionShow schema
System prompt as a string
stringSystem prompt as content blocks
Common Anthropic content blocks. Native dispatch can carry additional provider-specific blocks; conversion paths only preserve supported content. Cross-provider reasoning is emitted as text, never as forged signed thinking blocks.
typestringrequiredtextstringrequiredcache_controlobjectShow schema
typestringrequiredttlstringtypestringrequiredidstringrequirednamestringrequiredinputobjectrequiredtypestringrequiredtool_use_idstringrequiredcontentunionrequiredShow schema
stringtypestringrequiredtextstringrequiredcache_controlobjecttypestringrequiredsourceunionrequiredis_errorbooleancache_controlobjectShow schema
typestringrequiredttlstringtypestringrequiredsourceunionrequiredShow schema
typestringrequiredurlstringrequiredtypestringrequiredmedia_typestringrequireddatastringrequiredcache_controlobjectShow schema
typestringrequiredttlstringtypestringrequiredthinkingstringrequiredsignaturestringPreserve provider-issued signatures when replaying history. Unsigned thinking blocks are stripped before upstream Anthropic calls.
typestringrequireddatastringrequiredstreambooleanEnable streaming responses
toolsarrayTool definitions
Show schema
namestringrequiredThe name of the tool
descriptionstringDescription of what the tool does
input_schemaobjectJSON Schema describing the tool's input parameters
cache_controlobjectShow schema
typestringrequiredttlstringtool_choiceobjectShow schema
typestringrequiredModel decides whether to use tools
typestringrequiredModel must use one of the provided tools
typestringrequirednamestringrequiredName of the specific tool to use
enable_debugbooleanEnable request debug capture. Gateway-only field; does not add debug information to the response.
tagsarrayOptional tags to categorize and label the request. Useful for filtering and grouping requests in analytics and logs. Can also be sent via the `x-edgee-tags` header as a comma-separated string.
Show schema
stringtemperaturenumbertop_pnumberthinkingobjectShow schema
typestringrequiredadaptive, disabled, or legacy enabled; supported modes depend on the model.
displaystringsummarized or omitted. Default display depends on the model.
budget_tokensintegerRequired for legacy enabled thinking; adaptive models do not use this budget.
output_configobjectOnly effort is portable through the shared representation. Other fields such as format and task_budget are provider-native and are not preserved by every cross-format path.
Show schema
effortstringRequested effort; common values include none, minimal, low, medium, high, xhigh and max. The supported vocabulary is model-specific. Cross-format routing maps supported values and can omit unrepresentable levels.
Native dispatch preserves provider-specific JSON fields when the destination supports the caller’s format. Cross-format routing converts through the Gateway’s shared representation: provider-only features are not guaranteed to survive. Support for reasoning, images, built-in tools and structured outputs depends on the destination model.
modelstringrequiredModel identifier from GET /v1/models, in author/model format, or a configured global alias. Append :provider to request a specific provider route. Available models and providers depend on your key and organization policies.
inputunionrequiredThe input to the model. Either a plain string (treated as a single user message) or a flat array of typed input items (messages, function calls, function call outputs).
Show schema
stringTyped input items understood by the shared converter. additional_tools supplies inline tool declarations. Native Responses accepts further item types. On cross-format conversion unrecognized items (including replayed reasoning/computer items) are skipped; do not assume provider-only conversation state is portable.
rolestringrequiredThe role of the message author.
contentunionMessage content. Either a plain string or an array of typed content parts.
Show schema
stringtypestringrequiredtextstringrequiredtypestringrequiredtextstringrequiredtypestringrequiredtextstringrequiredtypestringrequiredimage_urlstringrequiredImage URL or data URL.
detailstringtypestringrequiredimage_urlobjectrequiredProvider-native parts are not portable across all formats.
objecttypestringrequiredcall_idstringrequiredIdentifier linking this call to its `function_call_output`.
namestringrequiredName of the function the assistant is calling.
argumentsstringArguments passed to the function, encoded as a JSON string.
typestringrequiredcall_idstringrequiredIdentifier matching the `function_call` item this is responding to.
outputunionrequiredTool result as text or multimodal content parts.
Show schema
stringtypestringrequiredtextstringrequiredtypestringrequiredtextstringrequiredtypestringrequiredtextstringrequiredtypestringrequiredimage_urlstringrequiredImage URL or data URL.
detailstringtypestringrequiredimage_urlobjectrequiredProvider-native parts are not portable across all formats.
objecttypestringrequiredrolestringtoolsarrayShow schema
Function, freeform and namespaced tools are understood by the converter. Namespaces are flattened for dispatch and restored on returned function calls. Other provider-native types can pass through natively but are dropped during typed conversion.
typestringrequirednamestringrequireddescriptionstringparametersobjecttypestringrequirednamestringrequireddescriptionstringformatobjectNative grammar constraint. Cross-format conversion uses an input string parameter and does not enforce the grammar.
typestringrequirednamestringrequiredtoolsarrayinstructionsstringSystem-level instruction prepended to the conversation. An alternative to including a `system` role message in the `input` array.
streambooleanIf set, the response is streamed as Server-Sent Events (SSE).
max_output_tokensintegerMaximum number of tokens to generate.
toolsarrayTools available to the model. Uses the Responses API flat format (no nested `function` key).
Show schema
Function, freeform and namespaced tools are understood by the converter. Namespaces are flattened for dispatch and restored on returned function calls. Other provider-native types can pass through natively but are dropped during typed conversion.
typestringrequirednamestringrequireddescriptionstringparametersobjecttypestringrequirednamestringrequireddescriptionstringformatobjectNative grammar constraint. Cross-format conversion uses an input string parameter and does not enforce the grammar.
typestringrequirednamestringrequiredtoolsarrayShow schema
Function, freeform and namespaced tools are understood by the converter. Namespaces are flattened for dispatch and restored on returned function calls. Other provider-native types can pass through natively but are dropped during typed conversion.
typestringrequirednamestringrequireddescriptionstringparametersobjecttypestringrequirednamestringrequireddescriptionstringformatobjectNative grammar constraint. Cross-format conversion uses an input string parameter and does not enforce the grammar.
typestringrequirednamestringrequiredtoolsarraytool_choiceunionTool selection on native Responses paths. Cross-format conversion supports modes and the shared nested function form; flat forced-function names are not preserved on every conversion path.
Show schema
Bare-string mode. `auto` lets the model decide; `none` forbids tool calls.
auto | none | required | anystringObject form of a tool selection mode.
typestringrequiredNative Responses forced-function form. The shared typed tool-choice representation uses {type:function,function:{name:...}}; the flat name is not preserved on every cross-format path.
typestringrequirednamestringrequiredName of the function to call.
temperaturenumberSampling temperature. Range and support depend on the destination model.
top_pnumberNucleus sampling probability. Alternative to temperature.
tagsarrayOptional tags to categorize and label the request. Useful for filtering and grouping requests in analytics and logs. Can also be sent via the `x-edgee-tags` header as a comma-separated string.
Show schema
stringenable_debugbooleanEnable request debug capture. Gateway-only field; does not add debug information to the response.
reasoningobjectShow schema
effortstringRequested effort; common values include none, minimal, low, medium, high, xhigh and max. The supported vocabulary is model-specific. Cross-format routing maps supported values and can omit unrepresentable levels.
summarystringRequested reasoning display: auto, concise or detailed. May be omitted on destinations that cannot represent it.
Responses
200Request 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.
application/json
The original request payload with compressed content fields replaced. All fields not touched by compression (`model`, `temperature`, `top_p`, `stop_sequences`, etc.) pass through unchanged. A `compression` object is appended when tool-result trimming runs. When trimming is disabled by the request header, the original payload is returned without added compression metadata.
compressionobjectToken compression metrics appended when `/v1/compress` runs tool-result trimming.
Show schema
techniquestringrequiredThe compression technique applied. Always `tool` (tool-result trimming).
applied_strategiesarrayrequiredNames of the compression strategies that were applied to the request.
Show schema
stringcompression_ratenumberrequiredRemaining token ratio: compressed_input_tokens / uncompressed_input_tokens. 0.81 means 19% saved; 1 means no reduction (also used for empty input).
uncompressed_input_tokensintegerrequiredToken count of the original, uncompressed input.
compressed_input_tokensintegerrequiredLocal token count after compression. No provider is called and this count is not a provider billing measurement.
compression_time_msintegerrequiredWall-clock time taken to perform compression, in milliseconds.
errorstringHuman-readable error message if compression partially failed. Present only when an error occurred during compression.
tool_statsobjectPer-tool compression statistics. Present only when `tool_result_trimming` was applied.
{
"model": "openai/gpt-5.2",
"messages": [
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "What is the capital of France?"
},
{
"role": "assistant",
"content": "Paris."
},
{
"role": "tool",
"tool_call_id": "call_abc",
"content": "<trimmed>"
}
],
"tools": [
{
"type": "function",
"function": {
"name": "get_weather",
"description": "Get weather for a location",
"parameters": {
"type": "object",
"properties": {
"location": {
"type": "string"
}
}
}
}
}
],
"compression": {
"technique": "tool",
"applied_strategies": [
"tool_result_trimming"
],
"compression_rate": 0.81,
"uncompressed_input_tokens": 1000,
"compressed_input_tokens": 810,
"compression_time_ms": 12
}
}400Malformed request, invalid/disabled model or provider, or unsupported conversion.
application/json
OpenAI-shaped Gateway error. Native upstream errors can retain provider-specific details.
errorobjectrequiredShow schema
messagestringrequiredA human-readable error message.
typestringrequiredHigh-level error category.
codestringMachine-readable error code, for example unauthorized, invalid_json, bad_model_id, model_disabled, provider_disabled, usage_limit_exceeded, usage_unavailable, provider_error or internal_error. Not an exhaustive enum.
paramstringName of the request parameter that caused the error, when applicable.
401Missing or invalid API credentials.
application/json
OpenAI-shaped Gateway error. Native upstream errors can retain provider-specific details.
errorobjectrequiredShow schema
messagestringrequiredA human-readable error message.
typestringrequiredHigh-level error category.
codestringMachine-readable error code, for example unauthorized, invalid_json, bad_model_id, model_disabled, provider_disabled, usage_limit_exceeded, usage_unavailable, provider_error or internal_error. Not an exhaustive enum.
paramstringName of the request parameter that caused the error, when applicable.
500Internal processing error.
application/json
OpenAI-shaped Gateway error. Native upstream errors can retain provider-specific details.
errorobjectrequiredShow schema
messagestringrequiredA human-readable error message.
typestringrequiredHigh-level error category.
codestringMachine-readable error code, for example unauthorized, invalid_json, bad_model_id, model_disabled, provider_disabled, usage_limit_exceeded, usage_unavailable, provider_error or internal_error. Not an exhaustive enum.
paramstringName of the request parameter that caused the error, when applicable.