API Guide

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.

Claude API pricing and access guide — Opus, Sonnet, Haiku token prices

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.

How this is sourced. Prices are Anthropic's published per-tier rates, June 2026. Gateway availability and prices are from the live DataLLM Lab catalog. For an upgrade-decision deep-dive, see Claude Opus 4.8 vs 4.7.

Claude API pricing

The full current table, by model, per million tokens:

ModelInputOutputContext
Claude Opus 4.8$5$251M
Claude Opus 4.7$5$251M
Claude Sonnet 4.6$3$151M
Claude Haiku 4.5$1$5200K
Claude Fable 5 (suspended)$10$501M

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:

Claude output price per 1M tokens, by tierJune 2026 · pick the lowest rung that clears your barClaude Opus$25Claude Sonnet 4.6$15Claude Haiku 4.5$5
Chart: DataLLM Lab — Claude output price per 1M tokens by tier, June 2026. Opus costs 5× Haiku on output; most production traffic doesn't need the top rung.

Caching & batch discounts (the real bill)

Two discounts cut Claude bills more than tier choice often does:

How to get a Claude API key

  1. Sign up at the Anthropic Console (platform.claude.com) and verify your account.
  2. Add billing; new accounts usually get some trial credit.
  3. Create a key under API keys and copy it once.
  4. 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.

Written by
Kevin Fan

Founder of DataLLM Lab, the unified LLM gateway. Kevin tests models the boring way — same prompts, real costs, unedited outputs — and writes up what the runs actually show.

One API for every model

One API, every model.

Get a single API key for Claude Opus 4.7, GPT-5.4, and 300+ more — with automatic price comparison and routing to the best model for every request.