Docs menu
Concepts

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.

Cheapest per token ≠ cheapest request
The lowest headline token price isn't always the cheapest way to complete a call. Sluice compares the expected cost of the whole request across eligible providers, not just a sticker price.

The request pipeline

Every request runs through the same path:

  1. 1
    Authenticate & check budget
    Your key is validated, and Sluice confirms you have credit and that the key's spend limit allows the call.
  2. 2
    Cache lookup
    If an identical request was answered recently (temperature 0, or cache: true), that answer is returned instantly — no provider fee, milliseconds instead of seconds.
  3. 3
    Route to the cheapest capable provider
    Among the healthy providers that serve your model, Sluice picks the lowest-priced one — honoring allowed_providers, max_latency_ms, and any provider you pinned.
  4. 4
    Optional model optimization
    If you set optimize: true, Sluice may run a cheaper model in the same quality tier; otherwise your exact model runs, unchanged.
  5. 5
    Execute, with failover
    The 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.
  6. 6
    Return & receipt
    The 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

Automatic
Cheapest-capable routing, failover, exact-match caching at temperature 0, and a cost receipt on every response.
You opt in
A cheaper same-tier model (optimize: true), caching at non-zero temperature (cache: true), provider limits (allowed_providers, max_latency_ms), pinning a provider, and batches.
Steer it yourself
Every control above is a field on the request body — see Routing & savings for the exact options.