#caching of custom provider with base url
1 messages · Page 1 of 1 (latest)
Anthropic prompt caching: yes, but only in the “Anthropic Messages API” path, and in OpenClaw it’s currently wired up only for the provider id anthropic.
-
OpenClaw supports Anthropic prompt caching via
params.cacheRetention(none|short|long) when you’re using Anthropic API-key auth. It’s API-only; setup-token/subscription auth won’t honor caching.
Docs: https://docs.openclaw.ai/providers/anthropic#prompt-caching-anthropic-api -
If you’re using an Anthropic-compatible proxy with a “non-official” base URL, caching can still work as long as you configure it as the
anthropicprovider (so OpenClaw actually sends the caching params), e.g. overridemodels.providers.anthropic.baseUrlto your proxy URL. If you define it as a custom provider name (e.g.myproxy) even withapi: "anthropic-messages", OpenClaw currently won’t applycacheRetentionfor that provider.
Gemini prompt caching: not currently exposed in OpenClaw (no equivalent cacheRetention/“cached content” integration), so with Gemini you’re basically limited to proxy-layer caching (Cloudflare/Vercel/etc.) rather than provider-native caching.
If you tell me which setup you mean (Anthropic-compatible anthropic-messages proxy vs OpenAI-compatible proxy that serves Claude/Gemini), I can point to the exact config shape for that case.
ok so i amusing custom provider at the omment, how do i override the anthropic api baseurl?
To override the Anthropic endpoint, add an explicit anthropic provider entry under models.providers and set its baseUrl to your proxy.
Minimal (just override endpoint; keep using normal anthropic/<model> refs):
{
models: {
mode: "merge",
providers: {
anthropic: {
baseUrl: "https://your-proxy.example.com/anthropic"
// (optional) headers: { "x-foo": "bar" }
},
},
},
}
Then make sure you’re actually using anthropic/... as your model ref (since caching is only applied for provider id anthropic), e.g.:
{
agents: { defaults: { model: { primary: "anthropic/claude-opus-4-6" } } },
}
If your proxy exposes non-standard model IDs (not in the built-in catalog), you can also define them explicitly under the same anthropic provider:
{
models: {
mode: "merge",
providers: {
anthropic: {