Skip to main content
Coding agents and chatbots send the model the same context over and over: the system prompt, project files, the conversation history. In agent workloads that’s typically 80–97% of all input tokens. Prompt caching means you no longer pay full price for that repeated context: the model remembers the start of the request it has already processed, and reading it back from the cache costs at least 10× less than regular input.

What RuAPI gives you

  • Claude over the native Anthropic API — just like Anthropic. Requests to https://www.ruapi.ai/v1/messages are passed through with their cache_control markers unchanged, ttl included. Claude Code, the Anthropic SDK and agents set to the Anthropic provider get caching with no extra setup.
  • Claude over the OpenAI-compatible format — cached too. RuAPI passes cache_control markers on message blocks through to Claude and understands a single top-level marker (automatic caching), using the same syntax as OpenRouter. Anthropic’s own OpenAI-compatible layer doesn’t support caching.
  • GPT and DeepSeek — automatic. The cache kicks in by itself when the start of a request repeats; there’s nothing to configure.
  • Transparent usage. The API response shows how many tokens were read from and written to the cache, and the console shows the same for every request.
  • No VPN, no foreign-issued card. RuAPI is reachable from Russia directly, and you top up in USDT.

Pricing

See the exact rates for every model on the pricing page. A cache write costs a little more than regular input, so caching pays off as soon as the same context is sent a second time within the cache lifetime. Every hit extends the cache by another 5 minutes (or an hour).

Claude: how to turn caching on

Which format are you using?

One RuAPI key works with Claude in two formats: the native Anthropic format and the OpenAI-compatible format. How caching is turned on depends on which one you use. If you’re not sure, check any of these: Claude Code always uses the native Anthropic format and sets the cache markers itself, so there’s nothing to check. In the OpenAI-compatible format, caching only works when the request carries cache_control markers. For all the differences between the two formats, see OpenAI or Anthropic format.

Claude Code and coding agents

If an agent uses the OpenAI Compatible provider for Claude, caching only works when the agent itself sets cache_control markers. Most agents don’t in that mode, so the Anthropic provider is the safer choice for Claude.

Your own app: Anthropic SDK

Put a cache_control marker on the last block of the part of the request that doesn’t change — for example, a long system prompt. Everything before the marker goes into the cache.
To keep the cache for an hour instead of 5 minutes, use "cache_control": {"type": "ephemeral", "ttl": "1h"}.

Your own app: OpenAI SDK

In the OpenAI-compatible format the marker goes on a block in content, so a message that carries a marker has to send its content as a list of blocks rather than a string.
You can also get by with a single top-level cache_control marker — Anthropic calls this automatic caching. In that case RuAPI places the marker on the last block of the last message itself, just as Anthropic does, so this option works on all of our Claude channels. With each new message the marker moves forward, and the whole earlier conversation lands in the cache.
A request can carry at most 4 markers. A request start that’s too short isn’t cached; the minimum length depends on the model — for example, 512 tokens for Claude Sonnet 5.5 and Claude Opus 5.5.

GPT and DeepSeek: caching is automatic

  • GPT. If the first 1,024 or more tokens of a request match a recent request, the matching part is read from the cache. No markers needed.
  • DeepSeek. Caching is always on: a repeated request start is billed at the cache-hit price.
To get more cache hits, keep the part that doesn’t change — the system prompt, instructions, tool definitions — at the start of the request, and everything that changes at the end.

How to check that the cache worked

In the OpenAI format, prompt_tokens already includes the cached tokens, just as with OpenAI. The console shows the same for every request: Usage Logs → open an entry.

Comparison

Information about other services is based on the Anthropic and OpenRouter documentation (checked Oct 15, 2026); the OpenRouter 403 error is from our own check on Sep 30, 2026.

FAQ

  • The start of the request changed. Even one character before the marker — the current time, a random ID — means a new prefix and a new cache write.
  • The start of the request is too short for this model.
  • More than 5 minutes passed without requests (or an hour with "ttl": "1h").
  • Claude is called in the OpenAI-compatible format without cache_control markers.
Most likely the cache isn’t working, so the whole repeated context is billed at full price every time.
  1. Find out which format you use: open a Claude entry in the console’s Usage Logs and look at “Request path”. /v1/messages is the native Anthropic format: caching works just as with Anthropic (Claude Code sets the markers itself), and the usual reasons for misses are in the previous question. /v1/chat/completions is the OpenAI-compatible format: go through the steps below. Other ways to tell the format are in “Which format are you using?” above.
  2. Check whether the cache works: if the entry details show a “Cache Tokens” line, the cache was hit; if repeated requests never show it, caching isn’t working. In your own code, the same number is in usage.prompt_tokens_details.cached_tokens in the API response.
  3. Check whether your client sets cache_control markers: without them Claude doesn’t cache anything. Many agents don’t set markers in OpenAI Compatible mode, so pick the Anthropic provider there. In your own code, a single top-level cache_control marker is enough.
  4. If you go through another gateway, check its documentation for Claude caching in the OpenAI-compatible format specifically. Not every gateway has it: Anthropic’s own OpenAI-compatible layer doesn’t support caching, and APIYI’s documentation, for example, says the Claude cache discount only applies in the native Anthropic format (checked Oct 15, 2026). On RuAPI, Claude caching works in both formats.
A cache write costs 1.25× the regular input price (2× for the one-hour cache), but every read after that is at least 10× cheaper. If the context is sent at least twice, you’re already saving.
No. Caching works for any key: for Claude, cache_control markers are enough (Claude Code sets them itself), and for GPT and DeepSeek the cache is automatic.

Next steps