Sticky conversations
Reuse a provider’s prompt cache across turns, automatically or with a conversation tag that can earn the cache-hit rate.Malibu offers two levels of prompt-cache reuse:
Automatic prefix cache (no header)
For authenticated requests, the gateway derives a prefix-cache key from your request’s scaffold: the system prompt andtools, or the messages up to the first user turn. It uses that key without any client change. When a provider already holds that prefix, it can skip re-reading it, and prompt_tokens_details.cached_tokens reports the reuse. This is the field OpenAI-compatible agents read as cache reads.
Automatic hits are billed at the normal prompt rate. The key is scoped to your account, and it does not change which provider serves the request.
Sticky conversation tag (cache-hit rate)
Send an opaque, buyer-chosen tag on every turn of a conversation. Turns with the same tag carry a preference for the provider that served the earlier turns. The preference is not a guarantee: the router keeps the sticky provider only when it is also the top-ranked choice for the request, so turns often route elsewhere. When the sticky provider does serve the turn and reuses the shared prefix, the reused tokens are billed at the discounted cache-hit rate and reported incached_prompt_tokens.
"prompt_tokens": 53, "cached_prompt_tokens": 41, "prompt_tokens_details": {"cached_tokens": 41} on turn 2.
The header name uses an
X-MacProvider- prefix. That is the wire name the gateway accepts. There is no X-Malibu-Conversation alias.How it works
- The tag is opaque and buyer-chosen. Use a stable per-thread identifier such as a UUID or your app’s thread ID. An empty header is ignored. The gateway rejects whitespace-only tags, tags longer than 128 bytes, and characters outside
[A-Za-z0-9._:-]with400 invalid_conversation_tag. - The gateway HMACs the tag with your
account_idand forwards only the derived key. One buyer’sthread-42never collides with another buyer’sthread-42, and providers never see the raw tag. - Stickiness lasts up to the TTL that
/v1/modelsreports undertier1_disclosure.sticky_affinity.ttl_seconds(1,800 seconds on 23 Sep 2026). - Stickiness is a preference, not a guarantee. If the sticky provider is not the top-ranked choice, or is disconnected, busy, or draining, the request goes through normal routing and
cached_prompt_tokensis0. The cache-hit discount applies only on a sticky hit. cached_prompt_tokensis always present, so you can read it without checking first.
Privacy trade-off
When it wins, stickiness routes more of one conversation to one provider./v1/models states this directly: that provider can observe and correlate more of your traffic than under default routing. Omit the tag if that matters more than the discount.
To clear your sticky routing state, call:
Billing
Sticky cache hits are metered separately from fresh prompt tokens. See API → Usage object for both cache fields and Metering & billing for the formula.When to use a tag
- Chat UIs. Use one tag per thread so repeated system prompts and history get cached.
- Agent loops. Use one tag per task. Many tool-call turns share one long prefix.
- Long-context RAG. Retrieved documents in the system prompt stay warm across follow-ups.