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 4.8 and 4.7, $2/$10 for Sonnet 5, $1/$5 for Haiku 4.5 per million tokens, with the older Sonnet 4.6 still served at $3/$15. 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 tracks those tiers closely — Opus 4.8 and 4.7 list at the identical rate — but it is not purely per-tier: inside the Sonnet tier the newer Sonnet 5 lists below the older Sonnet 4.6, so price the model, not just the tier. Claude is a common default for agentic and high-stakes work, and it is priced above the cheapest options. It is worth being precise about what that premium buys: when we ran nine executed coding tasks across 13 models, 10 of them scored a perfect 9/9, several at a fraction of Claude's cost. The Claude tiers earn their rate on hard, long-horizon work, not on routine code — our measured numbers are below.
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 5 | $2 | $10 | 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; Sonnet 5 undercuts the older Sonnet 4.6 on both sides.
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:
What the tiers cost on real code
List prices give you the rate, not the bill. We ran the two upper Claude tiers — Sonnet 5 and Opus 4.8 — through our own executed coding harness: 13 models, nine Python tasks, temperature 0, max_tokens 4000, every returned solution run against assertions the model never sees. Here are the two Claude rows, with the cheapest and priciest perfect scores from the same run for scale:
| Model | Score | $/1,000 tasks | Avg latency |
|---|---|---|---|
| Claude Sonnet 5 | 9/9 | $1.67 | 7.2s |
| Claude Opus 4.8 | 9/9 | $4.05 | 6.1s |
| Qwen3 Coder Next (cheapest 9/9 in the run) | 9/9 | $0.10 | 7.0s |
| GPT-5.5 (priciest 9/9 in the run) | 9/9 | $8.83 | 10.5s |
DataLLM Lab executed test: real token usage × list price, scaled to 1,000 tasks. Nine executed Python tasks, one scored attempt each.
Two results are worth carrying into a tier decision. First, Opus 4.8 cost 2.4x Sonnet 5 on these nine tasks for the identical 9/9 score — and it was the faster of the two at 6.1s against 7.2s. So the Claude price ladder does not run the way people assume on latency: here the cheaper rung was the slower one, and dropping from Opus 4.8 to Sonnet 5 cost about a second per task rather than saving any. If you moved to Sonnet mainly to cut response time, that was not the lever. Second, both Claude models emitted 0 reasoning tokens, so their bill tracked the visible answer only. That matters when you compare list prices against reasoning models, whose hidden thinking tokens are billed as output and can turn a low sticker price into a higher per-task cost — in this run DeepSeek V4-Flash spent 568 reasoning tokens a task and MiniMax M3 spent 623.
What this test does not measure. It is nine short Python functions, one shot each, scored pass or fail. It says nothing about long-context reasoning, multi-file refactoring, agentic tool use, or non-Python work — exactly the ground where a top tier is most likely to earn its rate. We also did not run Haiku 4.5, Opus 4.7 or Sonnet 4.6, so we have no first-party number for those tiers. Full run: the 13-model coding cost benchmark. How it was measured: our methodology.
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-5, claude-haiku-4-5
max_tokens=1024,
thinking={"type": "adaptive"}, # adaptive thinking on the Opus and Sonnet tiers
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 4.8 Hardest work
- $5/$25, for the hardest agentic coding and reasoning. In our nine-task executed run it scored 9/9 — the same as Sonnet 5, at 2.4x the cost. Escalate to it, don't default to it. Opus 4.7 lists at the same $5/$25 but we did not run it.
Sonnet 5 Balanced default
- Most production work at $2/$10 — 60% cheaper on output than Opus, and below the older Sonnet 4.6 at $3/$15.
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.8 and 4.7, Sonnet 5, Sonnet 4.6 and Haiku 4.5 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.8", messages=[{"role":"user","content":"Hello"}])
Call Claude and 300+ models with one key
Claude Opus 4.8, Claude Sonnet 5, GPT-5.5, GLM-5.2 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 5 $2/$10 and the older 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 5 ($2/$10) is the mid tier and undercuts the older Sonnet 4.6 ($3/$15) on both sides; Opus 4.8 and 4.7 ($5/$25) are the flagships.
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 4.8 for hardest agentic coding/reasoning, Sonnet 5 ($2/$10) 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