Docs menu
Optimization

Caching

Don't pay to compute the same answer twice. Sluice serves identical requests from cache, and marks long repeated prompt prefixes for the provider's own prompt cache.

Exact-repeat cache

When an identical request comes in again, Sluice returns the stored answer instantly — no provider call, no provider fee, milliseconds instead of seconds. It's on by default at temperature 0 (where output is deterministic). Control it per request:

cache: true
Force caching on even when temperature is above 0 (you accept a reused answer).
cache: false
Turn caching off for this request.
cache_ttl
How long a cached answer stays reusable, in seconds. Default 3600 (one hour).
{
  "model": "gpt-4o",
  "messages": [{ "role": "user", "content": "Classify: 'ships in 2 days'" }],
  "temperature": 0,
  "cache": true,
  "cache_ttl": 86400
}

What a cache hit costs

A cached response has cost_usd: 0 and cached: true in its receipt. There's no provider fee; you pay only our small share of the saving versus the direct price — so repeats are dramatically cheaper, not free of charge.

Per account
The cache is scoped to your account. One customer's cached answers are never served to another.
Not for tool calls
Responses containing tool_calls are never cached — those are side-effecting and always run fresh.

Provider prompt caching

When a long prompt prefix repeats across calls — a big system prompt, chat history, or documents — Sluice marks it for the provider's prompt cache (e.g. Anthropic's), where that cached input is billed at a fraction of the normal price. This happens automatically; no code change.

Biggest wins
Caching pays off most for repetitive, deterministic work — classification, extraction, moderation — and for long shared context. Keep it off (cache: false) for personalized or time-sensitive answers.