Token Saving
Reduce token usage by optimizing input content before it reaches the model.
How It Works
- Request Arrives - Your app sends a normal API call
- Gateway Optimizes - Enabled transforms rewrite eligible text fields to use fewer tokens
- Forwarded to LLM - Optimized input is sent to the provider with no SDK changes
Compression Methods
Smart JSON Compression - Up to 20% savings
Converts eligible JSON objects or arrays in LLM inputs to TOON format - ideal for tool call responses and structured data.
HTML to Text
Strips HTML tags and extracts clean text - removes markup overhead from scraped pages or rich content.
Markdown to Text
Removes Markdown syntax characters that consume tokens without adding meaning for the LLM.
Text Compression
Compresses verbose plain text while preserving the original meaning. It removes low-value prose noise and separator noise while avoiding structured-looking lines.
Configuration Keys
Token saving is configured per API key. Enable only the transforms that match the traffic sent through that key.
{
"smart_json_compression": false,
"html_to_text": false,
"markdown_to_text": false,
"text_compression": false
}
Input-Only Behavior
Compression is applied only to input tokens before they reach the LLM. Responses are returned untouched. Your application code stays exactly the same - no SDK changes, no prompt rewrites, just lower costs.