CoreCodeDocs

Get the most from CoreCode

Caching and billing

Last updated: November 1, 2026

Every turn, Claude Code resends the system prompt, the tool definitions and the whole conversation. When that hits the prompt cache it is billed as a cache read, at 2.5–10% of the normal input price, 5% on Opus 5.5 and Sonnet 5.5. So the cache hit rate largely decides what you spend. Ways to save beyond caching are in Spending less on Claude Code.

Low hit rate? Check auto mode firstWith Claude Code's auto permission mode on and CLAUDE_CODE_DISABLE_EXPERIMENTAL_BETAS set, every tool call is preceded by an extra check request that almost never hits the cache; it shows as Non-stream in the usage logs. It can be more than half of your spend. See The cost of auto mode.

How caching is billed

Anthropic's prompt cache matches by prefix: a request reads the cache only if its beginning is identical to content cached before. A request's input is billed in three parts:

PartMeaningRelative to the input price
Cache readThe part identical to a cached prefix0.05× on Opus 5.5 and Sonnet 5.5; 0.1× on Haiku 5.5; 0.025× on Fable 5.1
Cache writeThe part newly written to the cache. Five-minute and one-hour entries are priced differentlyAbout 1.25× for five minutes, 2× for one hour
InputThe part that is not cached, usually a few tokens in Claude Code1×

Unit prices are on the Pricing page. In a normal Claude Code session each turn writes only the few hundred to few thousand new tokens, and the remaining hundreds of thousands are cache reads. Once the prefix changes, the whole context is written again at the write price, often hundreds of thousands of tokens at once.

What CoreCode does

When the cache breaks depends on what the client sends. The cases below are Claude Code's own behavior and are the same through any relay or directly with Anthropic.

The cost of auto mode

Claude Code's auto permission mode decides by itself whether an action may run instead of asking you each time. Each checked action still needs a judgement. From v2.1.278, when requests go through a gateway or proxy, Claude Code first asks the server to review actions inside the normal model requests, with no extra request. CoreCode passes those requests and the review results through unchanged: in a test on October 30, 2026, auto mode on Opus 5.5 and Sonnet 5.5 was reviewed by the server, with only the main conversation's requests and no extra cost.

When the server does not review, Claude Code falls back to the old way: before each tool call it sends a separate classifier request with part of the transcript and the pending action to a model, which decides whether to allow it. The official documentation states that on API keys or relays these classifier requests count toward token usage. On CoreCode, the sessions that fall back are almost all ones that set CLAUDE_CODE_DISABLE_EXPERIMENTAL_BETAS, which also turns server review off. Setting CLAUDE_CODE_AUTO_MODE_SERVER=0 does the same.

These checks can also be refused: a check hands the model part of the transcript and asks it to write out its reasoning before the verdict. On CoreCode we have repeatedly seen Anthropic's safety classifier refuse such requests as reasoning extraction (reasoning_extraction). What is refused is Claude Code's own check, not anything you wrote, and CoreCode does not penalize your account for it, but the same check is not forwarded again and a resend is stopped (see 403). Remove CLAUDE_CODE_DISABLE_EXPERIMENTAL_BETAS and let the server review, and these separate checks stop.

Which model the classifier uses when it falls back: Anthropic's default is Claude Sonnet 5. CoreCode serves Sonnet 5.5, Opus 5.5, Haiku 5.5 and Fable 5.1, not Sonnet 5, and under Anthropic's rules Claude Code then uses your session's model instead. So when you code with Opus, every check is billed at Opus rates too.

When it falls back to separate classifier requests, this is what they cost.

The problem is that only the first small part of this check hits the cache. The remaining tens of thousands of tokens are written again every time, and the next check cannot use what this one wrote. In one real case:

How to spot it

How to confirm auto mode is on

What to do

  1. Remove CLAUDE_CODE_DISABLE_EXPERIMENTAL_BETAS: check the env block of ~/.claude/settings.json, your project's .claude/settings.json and your shell profile, and delete it, along with any CLAUDE_CODE_AUTO_MODE_SERVER=0. CoreCode needs neither. Start a new session and auto mode is reviewed by the server, with no separate checks. /status showing Auto mode server as Enabled confirms it.
  2. Turn auto off when you do not need to leave it unattended: press Shift+Tab to switch to Manual or accept-edits mode, and the checks stop. To start every session in Manual, put this in ~/.claude/settings.json:
    {
      "permissions": {
        "defaultMode": "default"
      }
    }
    To start in accept-edits instead, use acceptEdits in place of default.
  3. Use a cheaper classifier model: since Claude Code v2.1.302 the environment variable CLAUDE_CODE_AUTO_MODE_MODEL sets the classifier model; give a full model ID. When you code with Opus, set it to claude-sonnet-5-5 and checks are billed at Sonnet rates:
    {
      "env": {
        "CLAUDE_CODE_AUTO_MODE_MODEL": "claude-sonnet-5-5"
      }
    }
    The classifier judges whether an action is safe, and a smaller model judges less well; weigh that yourself.
  4. Accept the cost: auto mode buys you not having to confirm each action. If you need it, this spend is expected and not a relay problem.

Other causes of misses

These change the prefix Claude Code sends, so the next turn rewrites the whole cache:

CaseDetails
Switching models mid-sessionThe cache is per model, so another model starts from zero. When you switch back, the original model's cache may have expired.
Changing thinking effort or /fastEffort and fast mode also change the request and break the cache.
Pausing for more than 5 minutesThe default cache lasts only 5 minutes; after a coffee break the first turn rewrites everything. If you pause often, see One-hour cache.
An MCP server connecting or disconnectingTool definitions come first in the request, so a change to the tool list changes the whole prefix. Keeping Claude Code's default MCP tool search on avoids this; do not set ENABLE_TOOL_SEARCH=false.
Enabling or disabling a pluginA plugin that brings an MCP server has the same effect as the previous row.
/compactCompacting rewrites the history, so the first turn after it writes again; afterwards the session is shorter and cheaper.
Upgrading Claude CodeA new version has a different system prompt, so the first turn after upgrading rewrites.
A new session, /clear, or --resume after a long timeA new session writes the cache from the start. When you resume an old session, its cache has most likely expired.

Editing CLAUDE.md does not break the cache right away, but it does not take effect right away either; it waits for /clear, /compact or a restart. How to write it well is in How to write CLAUDE.md.

To hit the cache more: finish a task in one session where you can, without switching models or thinking effort midway; when the context gets long, compact it with /compact rather than starting a new session and rebuilding the context.

One-hour cache

If you often stop to think for five to sixty minutes before continuing, have Claude Code write one-hour cache entries. Add one line to env in ~/.claude/settings.json (needs Claude Code v2.1.242 or later):

"CLAUDE_CODE_PROMPT_CACHE_TTL": "1h"

A one-hour cache write costs about 2× the input price, a five-minute write about 1.25×. With few pauses each write costs more; with many pauses the full rewrites you avoid save much more. CoreCode forwards the headers the one-hour cache needs unchanged, so nothing else needs setting.

Investigate in the logs

Open the Usage Logs and read consecutive requests of one session in time order:

In Claude Code, /usage (or /cost) shows this session's token usage and cost, and /context shows what is filling the context.

If the logs still do not explain it, send us the times of those requests from your usage logs and we can check the upstream account and routing.

Other models on the bill

Even if you only code with Opus, Haiku or Sonnet can appear on the bill, usually because of:

Find the matching records by time in the usage logs to see which model each one used and what it cost.