Skip to content
Skills Library
AI & agents · Analysis

claude-api-cost-optimizer

/claude-api-cost-optimizer

This skill should be used when code calls the Claude / Anthropic Messages API or Amazon Bedrock Claude models and the user asks to "reduce Claude cost", "optimise tokens", "make this LLM call cheaper or faster", "which Claude model should I use", "should I use batch or caching", or when writing or reviewing any new Claude API call site (Java SDK, Python, TypeScript, Bedrock InvokeModel or Converse). Apply it proactively whenever a Claude API request is created or modified.

Licence
MIT
Last repository change
08.11.2026

Assessment and security

100/ 100Class: good
Format25 / 25
Frontmatter with name and description, valid name, description up to 1,024 characters, name matching the folder.
Discoverability25 / 25
Description explains when to use the skill, has a reasonable length and uses third person.
Content35 / 35
At least 150 words and at most 500 lines, headings, step lists, examples or code.
Hygiene15 / 15
No placeholders such as TODO, no Windows paths, with a licence.
Riskno signals detected in the scan
Files in this package
2
Scripts
0
HTML comments
0
URLs in SKILL.md
0
Deprecation

No signals detected. Repository changed on 08.11.2026, without references to retired models or APIs.

Licence

MIT, open: use and modify while retaining author attribution.

What it does and when to use it

This skill should be used when code calls the Claude / Anthropic Messages API or Amazon Bedrock Claude models and the user asks to "reduce Claude cost", "optimise tokens", "make this LLM call cheaper or faster", "which Claude model should I use", "should I use batch or caching", or when writing or reviewing any new Claude API call site (Java SDK, Python, TypeScript, Bedrock InvokeModel or Converse). Apply it proactively whenever a Claude API request is created or modified.

Triggers from the description

reduce Claude costoptimise tokensmake this LLM call cheaper or fasterwhich Claude model should I useshould I use batch or caching
Original author description

This skill should be used when code calls the Claude / Anthropic Messages API or Amazon Bedrock Claude models and the user asks to "reduce Claude cost", "optimise tokens", "make this LLM call cheaper or faster", "which Claude model should I use", "should I use batch or caching", or when writing or reviewing any new Claude API call site (Java SDK, Python, TypeScript, Bedrock InvokeModel or Converse). Apply it proactively whenever a Claude API request is created or modified.

How it works

  1. Procedure
  2. Decision rules
  3. Output
Original SKILL.md headings · 47 lines, 463 words
SKILL.md preview
---
name: claude-api-cost-optimizer
description: >
  This skill should be used when code calls the Claude / Anthropic Messages API or Amazon Bedrock
  Claude models and the user asks to "reduce Claude cost", "optimise tokens", "make this LLM call
  cheaper or faster", "which Claude model should I use", "should I use batch or caching", or when
  writing or reviewing any new Claude API call site (Java SDK, Python, TypeScript, Bedrock InvokeModel
  or Converse). Apply it proactively whenever a Claude API request is created or modified.
metadata:
  version: "0.1.0"
---

# Claude API cost and latency optimiser

Review every Claude API call site in scope and produce a concrete, priced recommendation.

## Procedure

1. Locate call sites: grep for `messages.create`, `messages.stream`, `MessageCreateParams`, `AnthropicClient`,
   `InvokeModel`, `Converse`, `anthropic.claude`, `claude-` model strings, `count_tokens`, `batches`.
2. For each call site record: model ID, `max_tokens`, effort (`output_config.effort`), thinking config,
   `speed`, system prompt size, tools count, whether `cache_control` is present, call frequency and
   latency requirement (interactive, near-real-time, offline).
3. Apply the decision rules below and estimate monthly cost before and after.
4. Output a table: call site | current config | recommended config | est. $ before -> after | latency impact | risk.
5. Offer patch-ready code changes. Never change behaviour without an eval to confirm quality holds.

## Decision rules

- **Model tier**: start from the cheapest model that passes evals. Haiku 5.5 for classification, extraction,
  routing and subagents; Sonnet 5.5 for balanced coding/agentic work; Opus 5.5 as default for hard reasoning;
  Fable 5.1 only when evals prove Opus at high effort falls short. Check current prices in
  `references/pricing.md`; recheck the live pricing page if the date there is old.
- **Effort**: set explicitly. `low` for simple/high-volume/subagents, `medium` balanced, `high` complex,
  `xhigh`/`max` only with measured headroom. Lower effort before rewriting prompts to "think less".
  Keep top-level effort constant inside a cached conversation (changing it invalidates the cache).
- **Prompt caching**: any repeated prefix over 512 tokens (5.x models) reused within 5 min -> add
  `cache_control` (or top-level automatic caching). Reused 5-60 min apart -> `ttl: "1h"`. Order prefix
  tools -> system -> static docs -> history; breakpoint on the last block that stays identical. Max 4
  breakpoints. Verify with `cache_read_input_tokens`.
- **Batches**: no latency SLA -> Message Batches API (50% off, stacks with caching, results any order,
  match on `custom_id`, 24h window). Not with `stream`, `speed: "fast"`, or `max_tokens: 0`.
- **Fast mode** (`speed: "fast"`, Opus 5.5): only where output tokens/second matters to users; 2x price;
  does not improve time-to-first-token; fallback to standard speed is a cache miss.
- **max_tokens**: size to real output plus thinking; truncation (`stop_reason: max_tokens`) wastes the call.
- **Context**: trim tool outputs, paginate, cap `max_content_tokens` on web fetch, use context editing or
  compaction for long agents, delegate noisy reads to Haiku subagents.
- **Haiku 5.5 tier trap**: prompts over 100k tokens (cache reads count) pay 5x rates per request.
- **Images**: downscale; tokens = ceil(w/28) x ceil(h/28).
- **Routing**: count_tokens (free) or a Haiku classifier to send easy requests to cheap models.
- **Bedrock**: 20 MB request cap, no url/file image sources, automatic top-level caching unavailable on the
  legacy integration (use explicit breakpoints), features lag the first-party API.

## Output

Lead with the single biggest saving and its dollar figure. Then the table. Then patches. Then the eval
needed to confirm quality.
Files in this package (2)
  • SKILL.md 4 KB
  • references/pricing.md 1 KB

Versions

The database has no other skills named claude-api-cost-optimizer.

Database snapshot: 13.11.2026 · package version fa7e901056af (SHA-256 digest of the entire package)

Downloads in the last 30 days: 1 · ranking

Report a problem with this skill: harmful content, incorrect descriptions or an author’s removal request.

Similar skills

  • 100claude-integration-reviewer
    This skill should be used when reviewing, writing or debugging code that integrates with Claude (Anthropic API, Claude SDKs in Java/Python/TypeScript, Amazon Bedrock Claude, Claude Agent SDK, MCP clients), including requests like "review my Claude integration", "is this LLM code…
  • 100amazon-bedrock
    Builds generative AI applications on Amazon Bedrock. Covers model invocation (Converse API, InvokeModel), RAG with Knowledge Bases, Bedrock Agents, Guardrails, and AgentCore. Use when invoking models, setting up Knowledge Bases, creating agents, applying guardrails, deploying to…
  • 100amazon-bedrock
    Builds generative AI applications on Amazon Bedrock. Covers model invocation (Converse API, InvokeModel), RAG with Knowledge Bases, Bedrock Agents, Guardrails, and AgentCore. Use when invoking models, setting up Knowledge Bases, creating agents, applying guardrails, deploying to…
  • 100anthropic-sdk
    The Anthropic SDK (Python `anthropic`, TypeScript `@anthropic-ai/sdk`) calls Claude models through the Messages API. Use when a user asks to add Claude to an app, build a chatbot, stream Claude responses, give Claude tools (function calling), send images or PDFs, turn on…
  • 86api-cost-review
    Review application code that calls the Claude API / Anthropic SDK for token and cost optimizations (prompt caching, batching, model routing, output limits). Use when the user asks to cut API cost or review LLM call sites.
  • 100llm-cost-optimizer
    Use when you need to reduce LLM API spend, control token usage, route between models by cost/quality, implement prompt caching, or build cost observability for AI features. Triggers: 'my AI costs are too high', 'optimize token usage', 'which model should I use', 'LLM spend is…

Feedback and reports

Your message goes to Bartosz Sokoliński. An email address is needed only for a reply. See the privacy policy.