optimizing-for-cost-and-intelligence changedabout-claude/models/optimizing-for-cost-and-intelligence
Nearest release: v2.1.304, published under an hour after this site recorded the change. Shown because the two are within 24 hours of each other. Nothing here says the release caused the edit.
Recorded here
Lines+41added
Lines−50removed
From line
172
where the diff opens
First seen
14 Aug 2026
this site's first read of the page
Recorded edits24to this page, all time
The whole hunk
from line 172, old and new numbered
/
from line 172
172172
173173#### Turn on caching
174174
175Setup takes little work. [Automatic caching](https://platform.claude.com/docs/en/build-with-claude/prompt-caching#automatic-caching) places breakpoints for you; otherwise, the [Claude API skill](https://platform.claude.com/docs/en/agents-and-tools/agent-skills/claude-api-skill) that ships with Claude Code can add caching to an existing integration from one prompt, `/claude-api add prompt caching to this integration`. On the code that produced these measurements, it put one breakpoint on the system block and one on each of the two most recent user turns; [Explicit cache breakpoints](https://platform.claude.com/docs/en/build-with-claude/prompt-caching#explicit-cache-breakpoints) explains where to place them.
175Setup takes little work. [Automatic caching](https://platform.claude.com/docs/en/build-with-claude/prompt-caching#automatic-caching) places breakpoints for you; otherwise, the [Claude API skill](https://platform.claude.com/docs/en/agents-and-tools/agent-skills/claude-api-skill) that ships with Claude Code can add caching to an existing integration from one prompt:
176176
177Let Claude Code add caching for you
178
179```text
180/claude-api add prompt caching to this integration
181```
182
183On the code that produced these measurements, the skill put one breakpoint on the system block and one on each of the two most recent user turns; [Explicit cache breakpoints](https://platform.claude.com/docs/en/build-with-claude/prompt-caching#explicit-cache-breakpoints) explains where to place them.
184
177185#### What breaks the cache
178186
179187Keep per-request text in the newest user turn, after the last cache breakpoint, and make every cache-invalidating change at a natural break, such as the first request after a compaction. The cache is a byte-exact prefix match over the request in order (tools, then system prompt, then messages), so a change anywhere invalidates everything after it.
from line 321
313321* The usual case is over-specific instruction added to compensate for an older model: "verify twice," "be maximally thorough," a mandatory step-by-step procedure, or a hand-rolled reasoning scratchpad.
314322* A newer model follows such instructions to the letter, producing extra tool rounds and extra writing, so the bill goes up with no gain in accuracy.
315323
316The audit is one command. The [Claude API skill](https://platform.claude.com/docs/en/agents-and-tools/agent-skills/claude-api-skill) that ships with Claude Code has a `prompt-audit` command that reads a project's prompts and request code and reports what was written for a different model. This shortened excerpt shows it run against a support-desk prompt and request code containing those patterns:
324The audit is one command. The [Claude API skill](https://platform.claude.com/docs/en/agents-and-tools/agent-skills/claude-api-skill) that ships with Claude Code has a `prompt-audit` command that reads a project's prompts and request code and reports what was written for a different model:
317325
326Let Claude Code audit your prompts for you
327
328```text
329/claude-api prompt-audit
330```
331
332This shortened excerpt shows the command run against a support-desk prompt and request code containing those patterns:
333
318334```text wrap
319335$ claude
320336> /claude-api prompt-audit
from line 658
642658
643659The following example computes one request's cost at Claude Opus 5.5's list prices. Change the three prices for another model:
644660
645<CodeGroup>
646 ```bash cURL
647 INPUT_PER_MTOK=4.00 # Claude Opus 5.5
648 CACHE_READ_PER_MTOK=0.20 # 0.05x the input price on Claude Opus 5.5; the multiplier differs by model
649 OUTPUT_PER_MTOK=20.00
661<CodeGroup exclude="shell:cURL, shell:CLI">
662 <CodeGroupItem language="cURL">
663 This calculation needs more logic than a single shell command. Use the [Claude SDK](https://platform.claude.com/docs/en/cli-sdks-libraries/overview) to run it.
664 </CodeGroupItem>
650665
651 response=$(curl --fail-with-body -sS https://api.anthropic.com/v1/messages \
652 -H "x-api-key: $ANTHROPIC_API_KEY" \
653 -H "anthropic-version: 2023-06-01" \
654 -H "content-type: application/json" \
655 -d '{
656 "model": "claude-opus-5-5",
657 "max_tokens": 1024,
658 "messages": [{"role": "user", "content": "Hello, Claude"}]
659 }')
666 <CodeGroupItem language="CLI">
667 This calculation needs more logic than a single shell command. Use the [Claude SDK](https://platform.claude.com/docs/en/cli-sdks-libraries/overview) to run it.
668 </CodeGroupItem>
660669
661 cost=$(jq -r --argjson in_price "$INPUT_PER_MTOK" --argjson read_price "$CACHE_READ_PER_MTOK" --argjson out_price "$OUTPUT_PER_MTOK" '
662 .usage
663 | (.input_tokens * $in_price
664 + (.cache_creation.ephemeral_1h_input_tokens // 0) * $in_price * 2.00 # 1-hour cache write
665 + (.cache_creation.ephemeral_5m_input_tokens // 0) * $in_price * 1.25 # 5-minute cache write
666 + (.cache_read_input_tokens // 0) * $read_price # cache read
667 + .output_tokens * $out_price) / 1e6
668 ' <<<"$response")
669 printf 'Request cost: $%.6f\n' "$cost"
670 ```
671
672 ```bash CLI
673 INPUT_PER_MTOK=4.00 # Claude Opus 5.5
674 CACHE_READ_PER_MTOK=0.20 # 0.05x the input price on Claude Opus 5.5; the multiplier differs by model
675 OUTPUT_PER_MTOK=20.00
676
677 USAGE=$(ant messages create \
678 --model claude-opus-5-5 \
679 --max-tokens 1024 \
680 --message '{role: user, content: "Hello, Claude"}' \
681 --transform usage)
682
683 COST=$(jq -r --argjson in_price "$INPUT_PER_MTOK" --argjson read_price "$CACHE_READ_PER_MTOK" --argjson out_price "$OUTPUT_PER_MTOK" '
684 (.input_tokens * $in_price
685 + (.cache_creation.ephemeral_1h_input_tokens // 0) * $in_price * 2.00 # 1-hour cache write
686 + (.cache_creation.ephemeral_5m_input_tokens // 0) * $in_price * 1.25 # 5-minute cache write
687 + (.cache_read_input_tokens // 0) * $read_price # cache read
688 + .output_tokens * $out_price) / 1e6
689 ' <<<"$USAGE")
690 printf 'Request cost: $%.6f\n' "$COST"
691 ```
692
693670 ```python Python
694671 INPUT_PER_MTOK = 4.00 # Claude Opus 5.5
695672 # 0.05x the input price on Claude Opus 5.5; the multiplier differs by model
from line 870
893870
894871### Automate the search with the Claude API skill
895872
896Run the [Claude API skill](https://platform.claude.com/docs/en/agents-and-tools/agent-skills/claude-api-skill)'s `cost-optimize` command before you search for savings. It profiles where your tokens go and applies the levers in order, caching first. Then run `/claude-api hillclimb` in the directory that holds your evaluation.
873Run the [Claude API skill](https://platform.claude.com/docs/en/agents-and-tools/agent-skills/claude-api-skill)'s `cost-optimize` command before you search for savings. It profiles where your tokens go and applies the levers in order, caching first:
874
875Let Claude Code find savings for you
876
877```text
878/claude-api cost-optimize
879```
880
881Then run the `hillclimb` command in the directory that holds your evaluation:
882
883Let Claude Code run the search for you
884
885```text
886/claude-api hillclimb
887```
897888
898889Anthropic measured the first lever of `cost-optimize` and two searches on tau2-bench retail[24](https://platform.claude.com/docs/en/about-claude/models/optimizing-for-cost-and-intelligence#refs), all on earlier models. The cache breakpoints that `cost-optimize` produced cut cost per task, and the pass rate fell by less than the spread of identical runs.
899890
No line in this hunk matches that.