deniz.in

Markets

Weather

Loading weather

· via dev.to (home feed)

Developer audit: third-party Claude API proxies can silently break or fake prompt caching

A developer who audited more than a dozen third-party Anthropic API relays says many break or fake prompt caching, and shares a two-request test for checking any provider.

Developer audit: third-party Claude API proxies can silently break or fake prompt caching

A developer who says an audit of more than a dozen third-party relays for Anthropic's API found that many of them silently break, or outright fake, the prompt caching that keeps costs down for heavy Claude Code and Cline users. In a post on dev.to, Denny Ho lays out four common failure modes, the break-even math for when caching stops paying off, and a two-request test for auditing any provider.

How prompt caching is supposed to work

According to the post, Anthropic charges 1.25 times the base input price to write a cache checkpoint and 0.1 times to read one back, which can amount to discounts of up to 90% on large contexts. Two constraints matter here. Caches are held per upstream account with a five-minute time-to-live, and a cache hit requires the prompt prefix to match byte for byte. Each failure mode Ho describes exploits one of those constraints.

Four ways proxies break caching

Ho groups the problems into four traps:

  1. Key pooling without session affinity. Budget relays often rotate requests across a pool of upstream API keys. Because each key keeps its own cache, a request landing on a cold key triggers a fresh write: every turn pays the 1.25x write fee instead of a 0.1x read, which works out to 125% of the uncached price per turn.
  2. Stripping the cache_control block. Some resellers advertise steep discounts while claiming full compatibility, but their proxies remove the caching directive before forwarding to cheaper channels that never supported caching, then bill at standard uncached rates and pocket an unearned markup.
  3. Fabricated usage telemetry. Because a proxy controls the JSON that comes back, some inspect prompt prefixes with memory hashes and, on detecting repetition, inject inflated numbers into the cache_read_input_tokens field of the usage object. The client reports a cache hit while the backend bills full input rates.
  4. System prompt mutation. Middleman gateways that inject internal tracking tags, safety prompts or dynamic timestamps into the system prompt break the exact-prefix requirement. A single altered byte invalidates the cache breakpoint and forces a complete context re-read.

When caching stops paying for itself

The arithmetic in the post is straightforward: with writes at 1.25, reads at 0.10 and uncached input at 1.0, the average cost per turn at hit rate H is 1.25 x (1 - H) + 0.10 x H. Setting that equal to 1.0 puts break-even at roughly a 21.7% hit rate. The counterintuitive consequence is that if a proxy's unstable routing drags the hit rate below about 22%, prompt caching costs more than it saves, and users would be better off disabling it.

How to audit a provider

The test needs two sequential requests, sent about two seconds apart, with a static prefix larger than 1024 tokens marked for ephemeral caching. The first response should report cache_creation_input_tokens above 1024; the second should report cache_read_input_tokens above 1024 and return with visibly lower latency. The decisive step happens in the billing dashboard: the second request must be metered at the 0.1x read rate rather than standard input pricing. Since a proxy controls the usage object it returns, the invoice is what catches forged telemetry.

The post also includes a short Python script that sends the two probes against any provider endpoint and prints latency alongside the usage fields for each turn. Beyond the test itself, Ho recommends demanding per-request transparency, including request IDs, visible route switches and granular cache read and write counters, and starting with a deposit of $1 to $5 while verifying usage logs before scaling up.

A caveat worth noting

The author discloses a commercial interest: the audits were conducted while building API Route, an OpenAI- and Anthropic-compatible routing gateway with session stickiness. No specific providers are named, so the findings read as one vendor's account rather than a verified survey. That said, the failure modes follow mechanically from the caching constraints described above, and the audit method stands on its own regardless of who published it.

Why it matters

For anyone running Claude Code or Cline through a discounted third-party relay, prompt caching is often the difference between a manageable bill and an expensive one, and every one of these failure modes is invisible from the client: the CLI shows a cache hit either way, and only a cross-check against the invoice exposes the gap. The broader lesson extends past Anthropic: usage telemetry returned by a proxy is a claim, not evidence. Request IDs, per-request counters and billed amounts are the only ground truth, and a two-request test costing a few cents is cheap insurance before committing real spend.

  • #anthropic
  • #api
  • #llm
  • #prompt-caching
  • #cost-optimization

Related posts