Skip to content
Ruvicode logo
Ruvicode
USD
GuideAugust 22, 2026· Updated November 3, 2026·5 min read

Prompt Caching for AI Agents: How It Lowers Your API Bill

Agents resend the same prompt prefix on every tool call. How prompt caching bills those tokens at a lower rate, with real numbers from a live gateway.

If you run AI coding agents like OpenCode, Cline, Aider, or Cursor, most of your API bill comes from one avoidable cost. The same tokens get processed over and over, and you pay full price every single time.

A single agentic session resends its entire conversation history on every tool call. By turn 20, a request might carry 200,000 prompt tokens, and 95% of them are identical to the previous request. That is not a bug. It is how the chat completions API works. But paying full input price for tokens the model has already seen is money burned.

Prompt caching fixes this. And if you are not using it, you are overpaying by a lot.

What prompt caching actually does

When a request arrives, the provider checks whether the beginning of the prompt, the prefix, matches a recently processed one. If it does, that portion is served from a cache instead of being recomputed. Cached tokens are billed at a cache read rate, which on most models is far cheaper than the normal input rate.

How big the gap is depends on the model and moves with the market. On some models a cache read costs a tenth of an input token, on others about a fifth, and on a few there is no gap at all at a given moment. Each model page lists both rates side by side, so check them before you pick a model for a cache-heavy agent.

For an agent that resends a growing prefix on every turn, this is the single biggest cost lever available. Nothing else comes close.

Real numbers from live traffic

We enabled cached token billing on Ruvicode this week. Here is what an actual agentic session looks like on our gateway, using GLM-5.2.

A typical request mid-session:

prompt_tokens:      299,541
cache_read_tokens:  298,624  (99.7% of the prompt)
billable input:       917 tokens
cost:                $0.0144

The same request without caching would bill all 299,541 tokens at the full input rate. With 99.7% served from cache, all but 917 of those tokens billed at the cache read rate instead. On a long session with hundreds of turns, that difference compounds into serious money.

The interesting part: the person running this session did nothing special. No flags, no parameters, no code changes. Caching matched the repeated prefix automatically.

How it works on Ruvicode

Three things, and then you can forget about it.

1. Caching is automatic. We match prefixes for you on every request. There is no parameter to set and nothing to enable. If your request reuses a prompt prefix, the cached portion bills at the cache read rate. If it does not, every token bills at the normal input rate.

2. You can see it happening. Every response's usage object reports the cache split. Your dashboard shows, per request, how many tokens were cached and what percentage of the prompt that covers. The weekly chart and usage totals include cached token counts.

3. Model pages show the cache rate. The models catalog and each model page list the cached input rate next to the normal input rate wherever the model has one. You can compare cache economics across models before you commit.

Which workloads benefit most

Prompt caching pays off whenever the same prefix repeats.

  • Coding agents are the best case. Tool loops resend the whole conversation on every call, so most of each prompt is a cache hit after the first few turns. In October 2026, on the three most requested models on Ruvicode, more than 80 percent of all prompt tokens were cache reads.
  • Chat with long history benefits the same way. Every follow-up message carries the entire prior conversation.
  • Stable system prompts over 1,024 tokens get partial benefit even in one-shot workloads, if the same system prompt is reused across requests.
  • One-shot, unique prompts get nothing. If every request is completely different, there is no prefix to reuse and every token bills at the input rate. That is fair, and it is how it should work.

Cache pricing you can see

On Ruvicode, the cached input rate is a published rate, listed on the model page next to the input rate, and it applies automatically to the cached portion of every request. You know what a cached token costs before you send it, and every response reports the cache split and the exact charge, so you can check the result yourself.

Try it

Point your agent at the Ruvicode endpoint, run a real task, and watch the cached percentage climb in your usage dashboard.

export OPENAI_BASE_URL=https://api.ruvicode.com/v1
export OPENAI_API_KEY=rvcd_...

Agents work out of the box because the API is OpenAI-compatible. No SDK changes, no config files, no cache toggles. Run a task, open the usage page, and see how much of your prompt was served from cache.

Your wallet will notice the difference before your users notice anything at all.

Ready to start building?

Get your API key in under 2 minutes.

Get Started →
R

Ruvicode Team

The people who build and run Ruvicode