Compressor
Compressor strips redundant whitespace, boilerplate formatting, and exact-duplicate lines out of a request before it's routed to any LLM provider — fewer input tokens, same meaning. It's opt-in, configured per Mizan API key, and lives under Optimizer alongside Response Caching, Tracing, and Souq.
What it is
When Compressor is enabled for a key, Mizan runs a deterministic, pattern-based pass over every outbound request made with that key — normalizing whitespace and dropping exact-duplicate lines — before the request is forwarded anywhere else. The provider that ultimately serves the call sees a smaller, cleaner request carrying the exact same instructions.
How it works
Compression runs immediately after Aman in the gateway pipeline — the response-cache lookup, Auto Router classification, Switchboard resolution, and the actual call to the provider all only ever see the final (redacted and compressed) body. Detection and rewriting are regex/string-based, not an extra model call: it adds no latency and no cost to the request.
v1 applies six rules, in order, to every text message and text part (images and other non-text content pass through untouched):
- Strip invisible characters (zero-width spaces, byte-order marks, soft hyphens).
- Normalize line endings.
- Collapse runs of spaces/tabs within a line into one space, and trim trailing whitespace.
- Collapse three or more consecutive blank lines down to one.
- Drop a line that's an exact repeat of the line immediately before it.
- Trim leading and trailing whitespace from the whole message.
Content inside a fenced code block or an inline code span is set aside before any rule runs and restored byte-for-byte afterward — whitespace there is often semantically meaningful (indentation, formatting), so Compressor never touches it.
Enabling it per key
Compressor is off by default and configured per Mizan API key, not per request — there is no request-level header or field to turn it on. Enable it from the Compressor page, or from the Mizan Keys page, where each key's gear icon opens the same settings alongside Aman, Tracing, and Switchboard. Once enabled, compression applies automatically to every request made with that key — nothing to change in your application code.
Playground
The Compressor page's Playground tab lets you paste sample text and see exactly what would be stripped, without making a real API call — it runs the same transform the gateway uses in production, so what you see there is what a live request would produce.
Savings
Every compressed call records how many input tokens were removed and, priced against that call's actual served model, how much it saved — shown on the Compressor page and in Analytics. Unlike Response Caching's savings (which only apply to Mizan-billed calls), Compressor's savings are shown for BYOK calls too — fewer tokens sent lowers the bill either way, whoever pays it.
v1 scope & limits
Compressor v1 is deliberately non-lossy — it never summarizes, paraphrases, or drops content a model would need. Every rule either normalizes whitespace or removes an EXACT duplicate line; two lines that merely look similar are both kept. There is no semantic compression (no LLM pass to shorten a verbose prompt while preserving its meaning) — that would add latency and cost to every request, and is being kept separate from this zero-overhead layer, same reasoning as Aman's pattern-based-only v1.
Token-savings figures are estimates (a character-count-based approximation), not a real before/after count from the provider — there is no way to ask a provider what a request would have cost at its original, uncompressed size. Only text content is affected; images and other non-text parts of a multimodal message pass through untouched.