Claude API Cookbook

Practical 2026 reference for Anthropic API cost, pricing, and tier selection.

🔥 Launch tonight — Power Prompts PDF 50p (just 50p tonight)30 battle-tested Claude Code prompts · 8 pages · paste into CLAUDE.md · price reverts to £5

Free tools

Cost Calculator → Prompt-Pricing Recommender → Diff Summarizer → Skills Browser →

Visual references

Claude pricing tiers — 2026
Bar chart of Opus 4.7, Sonnet 4.6, Haiku 4.5 per-million input and output prices.
Claude vs GPT vs Gemini — radar
Five-axis comparison: coding, cost, speed, vision, context window.

All 58 reference pages

Claude Opus 4.7 vs Sonnet 4.6 Pricing
Side-by-side Anthropic API pricing for Claude Opus 4.7 and Sonnet 4.6 in 2026. Per-token cost, cache savings, and when each tier pays off.
How Much Does Claude Cost in 2026?
Complete breakdown of Claude API costs in 2026: Opus, Sonnet, Haiku pricing per token, prompt caching savings, and batch API discounts.
Claude Prompt Caching, Explained
How Claude's prompt caching works in 2026: what gets cached, the 5-minute TTL, cost math, and when caching breaks even.
Free Claude API Cost Calculator
Estimate your Anthropic API bill: input tokens, output tokens, cache hits, batch discount, across Opus 4.7, Sonnet 4.6, and Haiku 4.5.
Claude vs GPT-4 Pricing (2026)
Apples-to-apples 2026 API pricing comparison: Claude Opus 4.7 vs GPT-4o, Sonnet 4.6 vs GPT-4o mini, with quick break-even math.
Anthropic API Pricing in 2026
Complete 2026 Anthropic API price list: every model, every token type, plus batch and cache discounts.
How to Reduce Claude API Costs
Seven concrete techniques to cut your Anthropic API bill 50-90%: caching, routing, batch, structured output, retries, eval, and context pruning.
Claude Batch API: 50% Off
How the Anthropic Batch API works, the 24-hour SLA, the 50% pricing discount, and the workload patterns where it pays off.
Claude Haiku 4.5 Pricing
Anthropic Haiku 4.5 pricing: $1 per million input tokens, $5 per million output, plus cache and batch rates. Where Haiku makes sense.
Claude Sonnet 4.6 Pricing
Anthropic Sonnet 4.6 pricing breakdown: $3/M input, $15/M output, cache and batch rates, and the 80/20 of when Sonnet wins.
Claude Opus 4.7 Pricing
Claude Opus 4.7 API pricing: $15 per million input tokens, $75 per million output. When the most-capable tier earns its premium.
Claude Models Compared (2026)
Side-by-side comparison of all three Claude tiers in 2026: capability, latency, context window, and pricing.
Claude Extended Thinking Pricing
How Claude's extended-thinking mode is priced: thinking tokens count as output, plus when the latency and cost trade is worth it.
When to Use Opus vs Sonnet
Practical guide to choosing between Claude Opus 4.7 and Sonnet 4.6: workload patterns where each tier wins, with cost math.
Claude Skills vs Tools
Anthropic Skills and Tools both extend Claude's capabilities, but they work differently. When to reach for each, and how to browse what's available.
Claude Sonnet vs Haiku — Which to Use?
Decision guide for choosing between Claude Sonnet 4.6 and Haiku 4.5 in 2026. Per-token cost, latency, quality, and concrete workload examples.
Claude Opus vs Sonnet — For Coding Tasks
How Claude Opus 4.7 and Sonnet 4.6 compare on code generation, refactoring, and code review in 2026. Cost-per-PR analysis with real benchmarks.
Anthropic API vs OpenAI API — Pricing
Side-by-side pricing comparison of Anthropic's Claude API and OpenAI's API in 2026. Per-tier costs, cache discounts, batch savings, and which to pick.
Prompt Caching vs Batch API — Claude Savings
Compare Claude's two main cost-reduction features: prompt caching (90% off cached reads) and the Batch API (50% off everything). When each pays off.
Extended Thinking vs Standard Mode
When to enable Claude's extended-thinking mode vs standard inference. Cost, latency, and quality tradeoffs with concrete examples.
Claude Tools vs MCP — Decision Guide
When to use Claude's built-in tool calling vs Model Context Protocol (MCP) servers. Architecture, ergonomics, and concrete use cases.
Claude Cost Per Million Tokens — Explained
What 'cost per million tokens' actually means for the Claude API. Per-tier breakdown, output multipliers, and a worked example.
Claude Streaming vs Non-Streaming
When to use Claude's streaming API vs the standard request-response mode. Latency, complexity, and cost implications.
Claude API vs Self-Hosted Llama — Cost
When self-hosting an open-weights model like Llama saves money vs paying for the Claude API. Break-even math, GPU costs, and hidden expenses.
Claude API Rate Limits — By Tier
How Claude API rate limits work in 2026: per-minute token limits, per-day request limits, and how usage tiers level up automatically.
Claude Code Cost Per Session
How much does Claude Code cost per session, per day, and per month? Real cost breakdowns with cache savings, plus a free calculator.
AI Git Diff Summary Tool
Paste any git diff and get a plain-English summary, PR description, or commit message in seconds. Free, runs in your browser, BYO API key.
Claude API Token Counter
Count tokens in any Claude prompt and estimate the API cost across Opus 4.7, Sonnet 4.6, and Haiku 4.5. Free, runs in your browser.
Claude API Key Setup Guide
Step-by-step guide to getting an Anthropic API key in 2026: account setup, free tier limits, rate-limit tiers, and first API call.
Claude Python SDK — Quickstart Guide
Get started with the Anthropic Python SDK in 2026: install, send messages, stream responses, use prompt caching, and estimate costs.
Claude Context Window — 200K Tokens Explained
How Claude's 200K context window works in 2026: what fits, token counting, cost implications, and strategies for long-context workloads.
Claude Tool Use Pricing and Cost Guide
How Claude's tool use (function calling) affects API costs in 2026: tool definition tokens, result tokens, multi-turn overhead, and cost-reduction strategies.
Claude API JavaScript Examples (2026)
Complete guide to using the Claude API with JavaScript in 2026. Node.js quickstart, streaming, tool use, and prompt caching code examples using the official Anthropic SDK.
Claude Streaming API with TypeScript (2026 Guide)
How to stream Claude API responses in TypeScript using the Anthropic SDK. Includes typed event handlers, SSE parsing, Next.js integration, and error handling patterns.
Claude Node.js Streaming API (2026)
Node.js code examples for streaming Claude API responses. Covers basic SSE streaming, Express integration, error handling, and token-by-token output using @anthropic-ai/sdk.
Anthropic TypeScript SDK Guide (2026)
Complete reference for @anthropic-ai/sdk in TypeScript. Types, configuration, messages API, streaming, tool use, prompt caching, and error handling with full code examples.
Claude Vision & Multimodal API Guide
Send images to Claude using the Anthropic API. Python and Node.js examples for base64 images, URLs, PDFs, and multi-image analysis. Works with Sonnet 4.6 and Haiku 4.5.
Claude API Structured Output & JSON Mode
Force Claude to return valid JSON using tool use or system prompts. Python and Node.js examples for structured output, schemas, and parsing. Works with all Claude 4 models.
Claude API Error Handling, Rate Limits & Retry Logic
Handle Anthropic API errors correctly: rate limits (529), overload (529), timeouts, and auth errors. Python and Node.js retry patterns with exponential backoff.
Using Claude API with Python asyncio (AsyncAnthropic)
Use AsyncAnthropic to call Claude in async Python applications. Concurrent requests with asyncio.gather, async streaming, FastAPI integration, and performance tips.
Claude API Conversation History
How to implement multi-turn conversation history with the Claude API. Maintain context, manage token limits, and avoid common mistakes in Python and JavaScript.
Claude API Tool Use and Function Calling
How to use Claude's tool use (function calling) API. Define tools in JSON schema, handle tool_use responses, and close the loop in Python and JavaScript.
Claude Files API — Upload, Reference, and Manage Files
How to use Anthropic's Files API to upload documents, images, and PDFs once and reference them across multiple Claude API requests. Python and TypeScript examples.
Claude API Cost Optimization in 2026
A 2026 checklist for cutting Claude API spend: caching, routing, batch, prompt compression, output budgets, and live cost monitoring — with code.
Claude API Production Checklist
18 concrete items to verify before shipping a Claude API integration to production: keys, retries, caching, observability, fallbacks, and cost guardrails.
Claude API Enterprise Pricing
How Anthropic structures enterprise pricing for Claude in 2026: usage tiers, committed-spend discounts, dedicated capacity, SLAs, and what to negotiate.
Best Claude API Wrapper Libraries
Comparison of Claude API wrapper libraries and frameworks in 2026: official SDKs, LangChain, LlamaIndex, Instructor, Vercel AI SDK, and when to pick which.
Claude API Error 529 — Overloaded
What HTTP 529 means on the Anthropic API, why it spikes during peak hours, and the retry, fallback, and routing patterns that keep your service up.
Claude API Caching Strategies
Five production prompt-caching patterns for the Claude API: system-prompt caching, document caching, conversation caching, tool caching, and tiered caching.
Claude API Batch vs Streaming Cost
Side-by-side comparison of Claude API batch and streaming modes in 2026: per-token cost, latency profile, throughput, and the workloads each one fits.
Claude API Budget Tracking
How to track Claude API spend in production: per-request token logging, daily aggregation, per-user attribution, alert thresholds, and a reference dashboard.
Claude Computer Use API: Automate Desktop and Web Tasks
Complete guide to Anthropic's Claude computer use API in 2026. Learn how to pass screenshots, handle tool calls, and build desktop/web automation pipelines with Claude.
Running Claude API Requests in Parallel
How to run multiple Claude API requests concurrently in Python and TypeScript. Covers asyncio, Promise.all, rate-limit handling, and queue-based concurrency patterns for Anthropic's API.
Fine-Tuning Claude: What's Possible in 2026
Does Anthropic support Claude fine-tuning? Learn what custom training options exist in 2026, what to use instead, and how to get Claude to behave consistently without fine-tuning.
Claude API 429 — Rate-Limit Survival Guide
How to handle HTTP 429 from the Claude API in production. Exponential backoff, retry-after, jitter, and the patterns that keep your traffic flowing without DDoSing yourself.
Claude API Webhooks — Async Result Delivery
How to use webhooks with the Anthropic API in 2026. Cover the Batch API callback flow, verifying webhook signatures, and a complete Express/Flask receiver pattern.
Claude Go SDK — Quickstart
How to call the Claude API from Go in 2026. Covers the official SDK, streaming, prompt caching, tool use, and concurrency patterns for production Go services.
Claude Ruby SDK — Quickstart
Calling the Claude API from Ruby in 2026 — the official anthropic gem, streaming, prompt caching, tool use, and how to integrate with Rails background jobs.

Frequently asked questions

What is the Claude API Cookbook?
A free, independent reference covering Anthropic API pricing, prompt caching, the batch API, model tiers (Opus 4.7, Sonnet 4.6, Haiku 4.5), and tier-selection rules. 25 cross-linked pages and 4 free companion tools.
Is this affiliated with Anthropic?
No. This is an independent reference. Pricing reflects public Anthropic rates as of 2026-05; verify on anthropic.com/pricing before committing budget.
How do I estimate my Claude API bill?
Use the free Claude Cost Calculator at claude-cost-calc.vercel.app: enter monthly request volume, average input/output tokens, and a model — it returns a USD estimate including cache savings.
Which Claude model should I use?
Default to Sonnet 4.6 for most production workloads. Use Haiku 4.5 for high-volume classification or short responses. Reserve Opus 4.7 for long-context reasoning or agentic flows where a single mistake compounds.

Further reading from the indieweb

Independent writers covering the Anthropic API, prompt engineering, and the indie web of small dev blogs: