#caching of custom provider with base url

1 messages · Page 1 of 1 (latest)

worn lion
#

is it possible to enable caching or anthropic or gemini models when using a custom provider with a base url that is not official?

tulip lilyBOT
#

To help others find answers, you can mark your question as solved via Right click solution message -> Apps -> âś… Mark Solution

rare cedarBOT
# worn lion is it possible to enable caching or anthropic or gemini models when using a cust...

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 anthropic provider (so OpenClaw actually sends the caching params), e.g. override models.providers.anthropic.baseUrl to your proxy URL. If you define it as a custom provider name (e.g. myproxy) even with api: "anthropic-messages", OpenClaw currently won’t apply cacheRetention for 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.

worn lion
#

ok so i amusing custom provider at the omment, how do i override the anthropic api baseurl?

rare cedarBOT
#

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: {