compute once. reuse safely. pay less.
LLM APIs waste money when they recompute the same context over and over. Agent tool definitions, system prompts, codebases, policies, and long conversation prefixes are often identical between requests. surp.ivc.lol now uses a two-layer cache engine to avoid that waste while preserving live marketplace pricing.
Provider-side prefix caching stores the model's computed state for the beginning of a prompt. Reusing a cached prefix cuts input cost by -75% to -90% and can drop time-to-first-token dramatically compared to processing fresh input.
But normal cheapest-price routing can destroy those savings: request one goes to model A, request two goes to model B, so model A's warm cache is useless. Our router now keeps a recently selected model when it remains within 30% of the current cheapest eligible model. If the price gap grows beyond that, it switches back to the live cheapest option.
request 1 → cheapest model A → provider writes prefix cache request 2 → A is still within tolerance → reuse A → cache read request 3 → model B becomes 40% cheaper → switch to B
This balances two things that normally conflict: marketplace arbitrage and cache locality.
Some requests are completely repeatable: temperature zero, no tools, one response, and no streaming. For those requests, surp.ivc.lol stores the completed JSON response under a SHA-256 fingerprint of the full request.
When the exact request arrives again within the cache window:
X-Surp-Cache: HIT and cache metadata.We deliberately do not cache every request.
| request type | exact response cache | sticky/provider cache |
|---|---|---|
| temperature 0, no tools, non-streaming | eligible | eligible |
| streaming response | bypass | eligible |
| tool or agent call | bypass | eligible |
| creative/nonzero temperature | bypass | eligible |
multiple candidates (n > 1) | bypass | eligible |
Raw prompts are never persisted in the exact cache. The database contains only a SHA-256 request fingerprint and the completed response. Responses expire automatically and the cache is size-bounded.
temperature: 0 for deterministic tasks that may repeat.Every response reports its cache path:
X-Surp-Cache: HIT | MISS | BYPASS X-Surp-Cache-Type: exact-response X-Surp-Routing: sticky-within-tolerance | live-cheapest
The public status page shows exact-cache hit rate, tokens not recomputed, live cached answers, and sticky-route reuse. The same metrics are available as JSON at GET /api/stats.
Most gateways optimize either price or caching. Pure cheapest-price routing jumps between models and loses warm prefixes. Pure session pinning ignores cheaper market offers. Our approach treats cached computation as an economic asset: keep it while its savings beat the price gap, then move when the market moves enough to justify losing it.
Cache hits create measurable economic value: the network avoids an upstream model call and keeps the difference. Instead of capturing all of that value, surp runs an experimental off-chain reward ledger called SRP:
more usage → more shared cache → lower network costs
↑ ↓
SRP claim on revenue ← more rebates ← more margin
SRP's estimated redemption value is rebate pool ÷ outstanding SRP. As protocol revenue enters the pool, existing SRP gains claim value. Heavy users who create useful cache entries can push their effective marginal cost toward zero over time.
Live pool backing, SRP outstanding, holders, and implied value per SRP are visible on the status page. An agent can query its own balance with GET /api/rewards?payer=0x....
You don't have to trust the default routing. Every request can carry its own constraints without changing the combo:
| parameter | type | effect |
|---|---|---|
max_price_per_1m | float | Reject any model above this USD/1M-token ceiling. Returns 404 if nothing qualifies. |
provider | string or array | Pin routing to one or more providers (allow-list). Cheapest within the set wins. |
surp_bypass_cache | bool | Skip the exact-response cache entirely. Always calls the model, never returns a cached answer. |
surp/strict/<combo> | model prefix | Disable sticky routing for this request. Always picks the live cheapest, never reuses a model for cache locality. |
Example: cheapest coder, but never above $0.50/1M and never from the cache:
curl -X POST https://surp.ivc.lol/v1/chat/completions \\
-H "Content-Type: application/json" \\
-d '{"model":"surp/best-coding",
"max_price_per_1m": 0.50,
"surp_bypass_cache": true,
"messages":[{"role":"user","content":"write a binary search"}],
"max_tokens":100}'
Example: cheapest chat, but only from a specific provider:
curl -X POST https://surp.ivc.lol/v1/chat/completions \\
-H "Content-Type: application/json" \\
-d '{"model":"surp/best-chat",
"provider": "deepseek",
"messages":[{"role":"user","content":"hi"}],
"max_tokens":50}'
These guardrails compose. A request can pin a provider, cap the price, and bypass the cache at the same time. The surp/strict/ prefix layers on top of any combo, including custom ones (surp/strict/my/your-slug).
related: x402 LLM API · cheapest LLM API · x402 gateway · API docs · live cache metrics