Skip to main content
RouteHub calls Claude’s native Messages API, so Anthropic’s prompt caching works as documented by Anthropic. Mark the content you want cached with cache_control:
The second call with the same prefix reads the handbook from cache, at a fraction of the input price.

How markers are handled

For Claude, prompt_tokens includes cache reads and writes, so cost accounting stays correct. Usage also carries cache_read_input_tokens and cache_creation_input_tokens.

Check support

supports_prompt_caching answers True only where markers are honoured, which is Claude, directly or through OpenRouter.
OpenAI caches long prompts on its own, with no markers, and reports the hits in usage.prompt_tokens_details.cached_tokens. Gemini has a separate caching API. Both answer False from supports_prompt_caching even though their catalog entries carry a cache-read price.

Compress long Claude requests

Long cached histories still have to be uploaded on every call. Pass gzip=True, or set ROUTEHUB_GZIP_ON=1, to gzip the request body sent to Claude’s Messages API. OpenAI-compatible providers always get an uncompressed body.