Cache: Prewarm cache
metrecept_prewarm_cacheRefresh an about-to-expire Anthropic prompt-cache breakpoint with a one-token call so the next real turn reads the cache instead of paying for a fresh cache write.
Instructions
Refresh an about-to-expire Anthropic prompt-cache breakpoint for a session with a one-token call, so the next real turn reads the cache instead of paying a fresh cache write. Use it from an idle timer when a long Claude conversation is about to sit past the cache TTL. Not for the gateway's own exact-replay cache (it never touches it): use metrecept_create_chat_completion. Not for OpenAI or other vendors, whose prompt caching is automatic. Sends your transcript and your upstream key exactly like a chat call; nothing is stored. Unbilled by the gateway (returns billed:false, billed_usd 0; the vendor still charges its own tokens) and audit-logged. Errors: 400 prewarm_unsupported_model for non-claude models, 400 cache_autopilot_disabled when the gateway has cache autopilot off, 401/402 for a missing upstream key. Requires a Metrecept API key (METRECEPT_API_KEY env on stdio, or Authorization: Bearer on remote HTTP); results are scoped to that key's tenant only.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| model | Yes | Anthropic model id, must start with "claude" (e.g. "claude-sonnet-4-5"); other vendors cache automatically and are refused. | |
| messages | Yes | The conversation's current transcript (system, user and assistant turns in order). The cached prefix is computed from it; nothing is stored. | |
| session_id | Yes | Session id of the conversation to keep warm; the same id the client sends on its real chat turns. | |
| upstream_api_key | No | Optional Anthropic key for this call (else the configured upstream key env); forwarded, never stored. |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | Yes |