Optimize Anthropic API costs — model selection, prompt caching, batches,
Use when working with cost-tuning patterns.
token reduction, and usage monitoring.
Trigger with "anthropic pricing", "claude cost", "reduce anthropic spend",
"anthropic billing", "claude cheaper".
Standardmäßig ist der Prompt ausgewählt, der zuerst die Quelle prüft. Sie können zu einem direkten Befehl wechseln oder eine lokale Kopie herunterladen.
Quelldateien prüfen
Lesen Sie SKILL.md und alle von SkillsMP angezeigten Begleitdateien, bevor Sie sich für eine Installation entscheiden.
Mit Codex oder Claude installieren Kopieren Sie diesen Prompt, fügen Sie ihn in Codex, Claude oder einen anderen Assistant ein und lassen Sie die Skill-Seite prüfen und installieren.
Ein direkter Befehl überspringt den Prüf-Prompt. Prüfen Sie die Quelle, bevor Sie ihn ausführen.
Optimize Anthropic API costs — model selection, prompt caching, batches,
Use when working with cost-tuning patterns.
token reduction, and usage monitoring.
Trigger with "anthropic pricing", "claude cost", "reduce anthropic spend",
"anthropic billing", "claude cheaper".
allowed-tools
Read, Write, Edit
version
1.0.0
license
MIT
author
Jeremy Longshore <jeremy@intentsolutions.io>
tags
["saas","anthropic","claude","cost","pricing"]
compatibility
Designed for Claude Code
Anthropic Cost Tuning
Overview
Anthropic charges per token. Input tokens, output tokens, and cached tokens each have different prices. Here's how to minimize cost without losing quality.
Pricing (per million tokens)
Model
Input
Output
Cached Input
Batch Input
Batch Output
Claude Opus 4
$15.00
$75.00
$1.50
$7.50
$37.50
Claude Sonnet 4
$3.00
$15.00
$0.30
$1.50
$7.50
Claude Haiku 4.5
$0.80
$4.00
$0.08
$0.40
$2.00
Cost Reduction Strategies
Instructions
Step 1: Right-Size Your Model
// DON'T use Opus for everything// DO match model to task complexity:// Simple classification/extraction → Haiku (cheapest)const category = awaitclassify(text, 'claude-haiku-4-5-20251001');
// General coding/writing → Sonnet (balanced)const code = awaitgenerate(spec, 'claude-sonnet-4-20250514');
// Complex multi-step reasoning → Opus (best quality)const analysis = awaitanalyze(data, 'claude-opus-4-20250514');
Step 2: Prompt Caching (90% off input tokens)
// Cache your system prompt — pays for itself after 2 callsconst message = await client.messages.create({
model: 'claude-sonnet-4-20250514',
max_tokens: 1024,
system: [{
type: 'text',
text: longSystemPrompt, // Must be 1024+ tokenscache_control: { type: 'ephemeral' }, // Cache for 5 minutes
}],
messages,
}, {
headers: { 'claude-beta': 'prompt-caching-2024-07-31' },
});
// First call: cache_creation_input_tokens charged at 1.25x// Subsequent calls: cache_read_input_tokens charged at 0.1x (90% savings!)
Step 3: Message Batches (50% off everything)
// For non-urgent work — 50% cheaper, 24h processing SLAconst batch = await client.messages.batches.create({
requests: prompts.map((p, i) => ({
custom_id: `job-${i}`,
params: {
model: 'claude-sonnet-4-20250514',
max_tokens: 1024,
messages: [{ role: 'user', content: p }],
},
})),
});
// Sonnet: $1.50/$7.50 per MTok instead of $3/$15
Step 4: Reduce Token Count
// Trim conversation history — keep system + last N turnsfunctiontrimMessages(messages: MessageParam[], maxTurns = 10) {
if (messages.length <= maxTurns * 2) return messages;
return messages.slice(-(maxTurns * 2));
}
// Set tight max_tokens — don't pay for output you won't useconst message = await client.messages.create({
model: 'claude-sonnet-4-20250514',
max_tokens: 256, // Not 4096 if you only need a short answer
messages,
});
// Use concise system promptssystem: 'Reply in 1-2 sentences.'// Not a 500-word personality description