Claude API: Pricing, Keys & How to Call It
The Claude API gives you Anthropic's models — Opus, Sonnet, and Haiku — and the pricing splits cleanly by tier: $5/$25 for Opus, $3/$15 for Sonnet, $1/$5 for Haiku per million tokens. This guide has the full verified table, the two discounts that cut real bills (prompt caching and batch), how to get an Anthropic key, and how to call it in a few lines — directly with the Anthropic SDK or through a gateway alongside 300+ other models.
What the Claude API is
The Claude API is Anthropic's programmatic access to its model family — Opus (the flagship), Sonnet (the balanced workhorse), and Haiku (the cheap, fast tier). Pricing is set per tier rather than per individual model, which makes the cost model unusually simple. Claude leads independent coding benchmarks in 2026, so the API is a common default for agentic and high-stakes work — with the trade-off that it's pricier than the cheapest options.
Claude API pricing
The full current table, by model, per million tokens:
| Model | Input | Output | Context |
|---|---|---|---|
| Claude Opus 4.8 | $5 | $25 | 1M |
| Claude Opus 4.7 | $5 | $25 | 1M |
| Claude Sonnet 4.6 | $3 | $15 | 1M |
| Claude Haiku 4.5 | $1 | $5 | 200K |
| Claude Fable 5 (suspended) | $10 | $50 | 1M |
Per 1M tokens, USD, June 2026. Fable 5 is Anthropic's top model but is currently suspended. Opus 4.8 and 4.7 share the same price.
The Claude tier ladder
The clearest way to read Claude pricing is as a 5× ladder from Haiku to Opus on output — the expensive side. Pick the lowest rung that clears your quality bar:
Caching & batch discounts (the real bill)
Two discounts cut Claude bills more than tier choice often does:
- Prompt caching — repeated prompt prefixes (system prompts, long context, tool definitions) bill cached input at roughly 10% of the input price. For agents that resend the same context every turn, this is the biggest single saving.
- Batch API — non-interactive jobs submitted in bulk are about 50% off. Ideal for evals, bulk classification, and offline processing.
How to get a Claude API key
- Sign up at the Anthropic Console (platform.claude.com) and verify your account.
- Add billing; new accounts usually get some trial credit.
- Create a key under API keys and copy it once.
- Store it as an env var:
export ANTHROPIC_API_KEY=...— never hard-code it.
How to call the Claude API
Claude uses Anthropic's Messages API. With the official Anthropic SDK:
from anthropic import Anthropic
client = Anthropic(api_key="$ANTHROPIC_API_KEY")
msg = client.messages.create(
model="claude-opus-4-8", # or claude-sonnet-4-6, claude-haiku-4-5
max_tokens=1024,
thinking={"type": "adaptive"}, # adaptive thinking on Opus/Sonnet 4.x
messages=[{"role": "user", "content": "Review this function for bugs..."}],
)
print(msg.content)
For long outputs, stream and use the SDK's final-message helper. To reach Claude with the OpenAI SDK instead, call it through a gateway (below).
Which Claude model to use
Opus Hardest work
- Top agentic coding and reasoning; leads independent SWE-bench. $5/$25. Use where correctness pays.
Sonnet 4.6 Balanced default
- Most production work at $3/$15 — a third cheaper on output than Opus, still very capable.
Haiku 4.5 Cheap & fast
- $1/$5, high-volume and latency-sensitive tasks: classification, routing, extraction.
Pattern Escalate
- Route Haiku/Sonnet-first, escalate to Opus only on hard cases — most traffic stays cheap.
Choosing between the top two tiers specifically? See Claude Sonnet vs Opus.
Calling Claude through a gateway
If you call more than one provider, a gateway gives you Claude plus everything else under one OpenAI-compatible key — and automatic failover when Anthropic is rate-limited. DataLLM Lab carries Claude Opus 4.7/4.6 and Sonnet 4.6 today:
from openai import OpenAI
client = OpenAI(base_url="https://www.datallmlab.com/v1", api_key="$DATALLMLAB_API_KEY")
resp = client.chat.completions.create(model="anthropic/claude-opus-4.7", messages=[{"role":"user","content":"Hello"}])
Call Claude and 300+ models with one key
Claude Opus 4.7, Sonnet 4.6, GPT-5.4, Gemini 3.1 Pro and more — one OpenAI-compatible endpoint, live price comparison, automatic failover.
FAQ
How much does the Claude API cost?
Per 1M tokens: Opus (4.8/4.7) $5/$25; Sonnet 4.6 $3/$15; Haiku 4.5 $1/$5. Prompt caching cuts cached input to ~10% of input; the Batch API is ~50% off.
How do I get a Claude (Anthropic) API key?
Sign up at the Anthropic Console (platform.claude.com), add billing, create a key, set ANTHROPIC_API_KEY. Or reach Claude via a gateway like DataLLM Lab with one key for 300+ models.
What's the cheapest Claude model?
Haiku 4.5 ($1/$5) — best for high-volume, latency-sensitive tasks. Sonnet 4.6 ($3/$15) is the mid tier; Opus ($5/$25) the flagship.
Is the Claude API free?
It's paid, usually with trial credit for new accounts; no permanent free production tier. The claude.ai chat product is free for manual use, but API access is billed per token.
Which Claude model should I use?
Opus for hardest agentic coding/reasoning, Sonnet 4.6 as the balanced default, Haiku 4.5 for cheap high-volume tasks. Route cheaper-first, escalate to Opus on hard cases.
Is the Claude API OpenAI-compatible?
Natively it uses Anthropic's Messages format (the Anthropic SDK). Through an OpenAI-compatible gateway like DataLLM Lab you can use the OpenAI SDK and the same code as other providers.
DataLLM Lab