Caching Pixels You've Already Seen.

Liam walks through a worked example showing how flagging repeated screenshots with ephemeral cache control cuts a 50-turn computer-use task from 100,000 tokens to 10,000.

2:12 video2 min readWatch on YouTube

Liam, in for Professor Bear, walks through a token-cost problem specific to computer-use agents: a screenshot that has not visibly changed still gets billed again in full unless the API is told to remember it.

The naive loop that keeps rebilling

A fifty-turn computer-use task takes a screenshot on every turn. In the worked example, thirty-five of those turns show a desktop that has not changed at all, meaning the exact same image goes out again. The natural assumption is that repeating an identical image costs nothing extra since the model has already seen it. That is not how it works. The API re-tokenizes every screenshot from scratch, identical or not, at roughly two thousand tokens each, so those repeated turns spend seventy thousand tokens re-reading pictures Claude has already read.

The concrete uncached cost

Liam sizes the problem with a specific case: a fifty-turn task where the screen only ever looks like one of five distinct states, labeled A through E. Without caching, every one of those fifty screenshots is billed at full price, which comes out to fifty times two thousand tokens, or one hundred thousand tokens, for a screen that actually only changed five times.

The fix: one field

The fix is a single field, cache_control set to {"type": "ephemeral"}. Attaching it to a screenshot the first time it is sent tells the API to cache that exact image. Sending the identical screenshot again with the same flag produces a cache hit: the API recognizes it and skips re-tokenizing, so the agent still sends the picture but stops paying full price for the ones it has already seen.

What the fix actually saves

Applied to the fifty-turn, five-unique-state example, caching turns those fifty screenshots into five misses and forty-five hits. Five misses at two thousand tokens each is ten thousand tokens instead of one hundred thousand, a ninety percent savings on this specific task.

The scope limit

Liam is careful to mark the edges of the claim. This covers the screenshot case only; it does not walk through the full caching protocol, including the minimum cacheable size or the eviction rules. The cache is also not permanent. Switching API keys or leaving the session idle too long empties the cache regardless of whether the underlying screenshot ever changed, so the next screenshot becomes a miss again even if the desktop looks identical to a human watching.

Key takeaways

  • An identical screenshot is billed again in full by default; the API does not recognize repeats on its own.
  • A fifty-turn task with only five unique screen states can cost one hundred thousand tokens uncached versus ten thousand cached.
  • Setting cache_control: {"type": "ephemeral"} on a screenshot is what makes a repeat send a cache hit instead of a full re-tokenization.
  • The ninety percent savings figure comes from this specific worked case, not a guarantee for every deployment.
  • The cache does not survive an API key switch or a long idle gap, so a repeated screenshot can still miss after enough time has passed.

Who this is for

This is for developers building computer-use agents who want a concrete, low-effort way to cut token costs from repeated screenshots without changing anything else about the agent's loop.

Chapters

  1. 0:00It's the same screenshot, so sending it again is free, right?
  2. 0:12The naive loop, unpriced
  3. 0:38The concrete case: 100,000 tokens uncached
  4. 0:55One field: cache_control ephemeral
  5. 1:15Cut down, and the scope limit
  6. 1:39Carry-out
  7. 1:48Your turn
  8. 2:07Outro
Full transcript(auto-generated, with timestamps)

It's the same screenshot, so sending it again is free, right?

[0:00]Someone assumes an identical screenshot costs nothing extra to resend. It doesn't work that way. Every repeat gets billed again unless you tell the API to remember it. So, what actually stops the rebilling?

The naive loop, unpriced

[0:12]A 50-turn computer use task takes a screenshot on every turn. 35 of those turns, the desktop hasn't changed at all. The exact same image goes out again. The natural assumption is that repeating an image costs nothing extra since the model has already seen it. It doesn't work that way. The API retokenizes every screenshot from scratch, identical or not, at 2,000 tokens each. That's 70,000 tokens spent rereading pictures Claude has already read. Here's the concrete case. A

The concrete case: 100,000 tokens uncached

[0:39]50-turn task, but only five different things the screen actually looks like. Call them A through E. Without caching, every one of those 50 screenshots is billed at full price. 50 * 2,000 tokens is 100,000 tokens for screen that only changed five times. The fix is one

One field: cache_control ephemeral

[0:55]Field, cache_control type ephemeral. Attach it to a screenshot the first time you send it, and the API caches that exact image. Send the identical screenshot again with the same flag, and it's a cache hit. The API recognizes it and skips retokenizing for next to nothing. You still send the picture, you just stop paying full price for the ones it's already seen. Back to that 50-turn

Cut down, and the scope limit

[1:16]Task, five unique states cached means five misses and 45 hits. 5 * 2,000 is 10,000 tokens, not 100,000. 90% saved, but this is the screenshot case only. It doesn't cover the full caching protocol, minimum cacheable size, eviction rules, and the cache doesn't survive forever. Switch API keys or leave it idle too long, and the next screenshot is a miss again, cache or no cache. A repeated

Carry-out

[1:39]Screenshot doesn't get cheaper on its own. You have to flag it as one you've already shown, and the discount lasts only until the picture actually changes.

Your turn

[1:48]Your turn. Here's the prompt, read it with me. My computer use agent resends an identical screenshot up to 35 times in a 50-turn task at ephemeral prompt caching, and show me the token savings before and after. Ask Claude to write the caching wrapper, then check. Does it handle a screenshot that changed only slightly, not identically? Liam in for Bear.

Outro

[2:07]Caching pixels you've already seen. Lay them in for Bear.

More from Claude Basics

Humanitarians AI Lyrical Literacy Project