Docs menu
How it works
Sluice optimizes for the cost of a successful result — not just the lowest price per token. Here's the principle behind that, and the path every request takes.
Cost per result, not per token
Models are sold by the token, so it's tempting to always reach for the lowest per-token price. But the cheapest model can fail, need retries, or return something your app can't use — and a cheap token that produces a wrong answer is expensive. Sluice optimizes for the lowest total cost of a result that actually meets your needs: it routes to the cheapest provider that can serve your model, fails over when one is down, and never silently downgrades your model unless you opt in.
The request pipeline
Every request runs through the same path:
- 1Authenticate & check budgetYour key is validated, and Sluice confirms you have credit and that the key's spend limit allows the call.
- 2Cache lookupIf an identical request was answered recently (temperature 0, or cache: true), that answer is returned instantly — no provider fee, milliseconds instead of seconds.
- 3Route to the cheapest capable providerAmong the healthy providers that serve your model, Sluice picks the lowest-priced one — honoring allowed_providers, max_latency_ms, and any provider you pinned.
- 4Optional model optimizationIf you set optimize: true, Sluice may run a cheaper model in the same quality tier; otherwise your exact model runs, unchanged.
- 5Execute, with failoverThe request is sent. If that provider errors or times out and a retry is safe, Sluice moves to the next capable provider so your call still succeeds.
- 6Return & receiptThe answer streams back (or returns whole) with a sluice cost object attached, and the usage is recorded for your dashboard.
Reliability & failover
Cheap inference is only useful if your calls actually succeed. Sluice tracks provider health, caps how long a request can wait on an unresponsive provider, and retries on another eligible provider when the first one fails — within limits, and only when retrying is safe for that request. Failover always respects your constraints: your model, your allowed_providers, and your latency ceiling.
What's automatic vs. what you control
optimize: true), caching at non-zero temperature (cache: true), provider limits (allowed_providers, max_latency_ms), pinning a provider, and batches.