Provider pinning and cache locality
A conversation is cheaper and faster when its follow-ups land where the history is already cached. Pins and affinity are how you keep them there.
Published by the Foglare team, a four minute read about pins and prefix caches.
The affinity echo
{
"model": "auto:M",
"previous_response_id": "fglr_...",
"messages": [
{ "role": "user", "content": "Now rewrite it shorter." }
]
} Echo the last response id; the gateway stays on that provider for this turn.
What a prefix cache is
When a provider processes a conversation, it can cache the work done on the prefix — the system prompt and the history so far. A follow-up that starts with the same prefix reuses that cached work instead of re-processing every earlier token. The longer the conversation, the more that reuse is worth.
The catch: the cache lives on the provider that built it. A follow-up routed to a different provider starts cold. That is the whole reason locality matters in a gateway that otherwise picks the healthiest target on every request.
Affinity keeps the cache warm
Every Foglare response carries an opaque id. Send it back as
previous_response_id on the next request and the gateway keeps
you on the same provider — without you naming a vendor. It works with the routing tiers:
you keep asking for auto:M, and the conversation keeps its
provider.
Affinity is a preference, not a cage: if the pinned-by-history provider is unavailable, the gateway still routes your request rather than failing it. You lose the warm cache for that turn, not the answer. Your dashboard's usage panel counts cached tokens separately, so you can see the reuse happening.
Pins: per request and saved
A pin names the provider outright. Send the optional provider
field with a codename from the models page
and that one request stays on it. Or save a pin from the dashboard or models page while
signed in, and every browser-session request for that model uses it until you change or
remove it. A per-request pin always wins over a saved pin.
One-request pin
{
"model": "qwen4-max",
"provider": "sigma",
"messages": [
{ "role": "user", "content": "Hello" }
]
} Codenames are listed per model on the models page; the pin holds for this call only.
- Per-request pin
- The provider field on one call. Highest precedence.
- Saved pin
- Set from the dashboard or models page; applies to signed-in browser requests.
- Affinity
- previous_response_id keeps a conversation on its provider without a pin.
- No pin at all
- The gateway picks the healthiest target for the tier on every request.
- Anonymous calls
- No session, no saved pins; the shared pool answers and per-request pins still work.
When to pin, when not to
Pin when you have a reason to stay: a long conversation whose prefix cache is worth keeping, a provider whose output you have evaluated, or your own linked Logfare capacity and its quota. Leave it unpinned when you want the gateway's default behavior — the healthiest target for the tier, with failover doing its job. The routing mechanics behind that default are in How routing tiers work.
One caution: a pin is a commitment to a single provider's health. If it degrades, your pinned requests feel it before the pool does. Check the models page status before pinning, and unpin when the reason goes away.
Pinning in the docs