Independent & unofficial. Not affiliated with Anthropic. Facts verified 21 August 2026. Always confirm pricing at claude.com/pricing.
Developer reference

The Claude API

A working developer's guide to the Claude API in August 2026: current model IDs and prices, a first request, caching, batching, tools and rate limits.

The Claude API is Anthropic's HTTP interface to the Claude models. You create a key at platform.claude.com, POST a JSON body to /v1/messages, and pay per token. As of August 2026 four models are callable - Fable 5, Opus 5, Sonnet 5 and Haiku 4.5 - from $1 to $10 per million input tokens.

This page is the working reference: keys, a first request in three languages, the full rate card, the parameters that now return a 400, caching and batching arithmetic, server tools, rate-limit tiers and the three cloud resellers. For a code-heavy production walkthrough - retries, streaming events, structured output, observability - continue to using Sonnet 5 in production.

#The Claude API at a glance

Console
platform.claude.com - keys, usage, spend caps
Endpoint
POST https://api.anthropic.com/v1/messages
Auth headers
x-api-key and anthropic-version: 2023-06-01
Official SDKs
Python, TypeScript, C#, Go, Java, PHP, Ruby
Cheapest model
claude-haiku-4-5 - $1 in / $5 out per MTok
Largest context
1,000,000 tokens, default, no beta header
Biggest cost levers
Prompt caching (reads at 0.1×) and the Batch API (flat 50% off)

#How do you get a Claude API key and make a first request?

Sign in at platform.claude.com, open Settings → API keys, and create one. The Console account is separate from a Claude Pro or Max subscription: a chat plan gives you no API credit, and an API key gives you no chat plan. If you only want Claude in a terminal rather than in your own product, the subscription route is cheaper - see Claude for developers and the plan breakdown on the pricing page.

Every SDK reads ANTHROPIC_API_KEY from the environment, so no key material belongs in your source. Anthropic also ships a small CLI, ant, with browser-based OAuth login, and supports Workload Identity Federation and key expiry for teams that cannot hold long-lived secrets.

#Python

pip install anthropic
import anthropic

client = anthropic.Anthropic()  # reads ANTHROPIC_API_KEY

message = client.messages.create(
    model="claude-sonnet-5",
    max_tokens=1024,
    messages=[
        {"role": "user", "content": "Summarise this contract clause in two sentences."}
    ],
)

for block in message.content:
    if block.type == "text":
        print(block.text)

print(message.usage.input_tokens, message.usage.output_tokens, message.stop_reason)

#TypeScript

npm install @anthropic-ai/sdk
import Anthropic from "@anthropic-ai/sdk";

const client = new Anthropic();

const message = await client.messages.create({
  model: "claude-sonnet-5",
  max_tokens: 1024,
  messages: [
    { role: "user", content: "Summarise this contract clause in two sentences." },
  ],
});

for (const block of message.content) {
  if (block.type === "text") console.log(block.text);
}

#cURL

curl https://api.anthropic.com/v1/messages \
  -H "content-type: application/json" \
  -H "x-api-key: $ANTHROPIC_API_KEY" \
  -H "anthropic-version: 2023-06-01" \
  -d '{
    "model": "claude-sonnet-5",
    "max_tokens": 1024,
    "messages": [
      {"role": "user", "content": "Summarise this contract clause in two sentences."}
    ]
  }'

The response carries id, role, a content array of typed blocks, stop_reason, stop_details and a usage object. Read content as a list of blocks, never as a string - with thinking on by default on the 5-generation models, content[0] is frequently a thinking block rather than text.

#What does the Claude API cost in August 2026?

Prices are per million tokens (MTok) and are the same at 9,000 input tokens as at 900,000 - there is no long-context surcharge on any current model. Cache writes and cache reads are billed as separate categories at fixed multiples of base input.

ModelAPI IDInput5-min cache write1-hour cache writeCache readOutput
Fable 5claude-fable-5$10$12.50$20$1$50
Opus 5claude-opus-5$5$6.25$10$0.50$25
Sonnet 5claude-sonnet-5$2$2.50$4$0.20$10
Haiku 4.5claude-haiku-4-5$1$1.25$2$0.10$5

Sonnet 5's $2/$10 rate was introductory at launch. On 10 August 2026 Anthropic made it permanent and cancelled the planned 1 September rise to $3/$15. One caveat before you model your savings: the tokenizer used by Sonnet 5, Opus 4.7 and later emits roughly 30% more tokens for the same English text than the tokenizer in Sonnet 4.6, so the naive 33% saving on the headline rate works out closer to about 13% once that higher token count is accounted for. Re-measure before assuming the full reduction.

Two side rates worth knowing. Setting inference_geo: "us" for US-only inference applies a 1.1× multiplier to every token category. And a research-preview "fast mode" on Opus 5 and Opus 4.8 buys up to 2.5× the output speed at $10/$50 per MTok - first-party API only, not on the cloud resellers, not in batches. If cost per task rather than cost per token is your question, the model comparison works it through by workload.

#Which parameters were removed, and what returns a 400?

This is where most migrations break. Three sampling parameters and one prompting technique no longer work on current models.

Breaking changes to check before you upgrade

temperature, top_p and top_k are gone on Opus 4.7 and later and on Sonnet 5 - passing a non-default value returns HTTP 400. Assistant message prefill was removed on 4.6 and later, so the old trick of seeding the reply with {"role": "assistant", "content": "{"} also 400s. Use tool use for structured output instead.

Replacing them is a change of mental model, not a change of syntax. Determinism used to be bought with temperature: 0; on the 5-generation models it is bought with a tight schema and an explicit instruction. Reasoning depth used to be bought with a token budget; it is now bought with effort.

#Thinking is on by default, and effort controls it

Opus 5, Sonnet 5 and Fable 5 all think before answering unless you tell them not to. The depth ladder is lowmediumhigh (the default) → xhighmax. Thinking tokens are billed as output tokens and count toward max_tokens, so raising effort raises your bill on the expensive side of the meter.

message = client.messages.create(
    model="claude-opus-5",
    max_tokens=8192,
    output_config={"effort": "low"},      # low | medium | high | xhigh | max
    messages=[{"role": "user", "content": "Classify this ticket: ..."}],
)

Turning thinking off entirely behaves differently per model. On Sonnet 5, thinking: {"type": "disabled"} works. On Opus 5 it is accepted only while effort is high or below - combine it with xhigh or max and you get a 400. On Fable 5 adaptive thinking cannot be disabled at all, and the raw chain of thought is never returned. Haiku 4.5 is the odd one out: it still uses the older extended-thinking mode with an explicit budget_tokens. The full mechanics are on extended and adaptive thinking.

#Streaming, system prompts and tool use

Set stream=True and the API returns server-sent events instead of one JSON body. This matters beyond user experience: on long generations a non-streaming request can exceed intermediary timeouts, and the SDKs will warn you when max_tokens is high enough to make that likely.

with client.messages.stream(
    model="claude-sonnet-5",
    max_tokens=2048,
    system="You are a precise technical editor. Never invent citations.",
    messages=[{"role": "user", "content": doc}],
) as stream:
    for text in stream.text_stream:
        print(text, end="", flush=True)
    final = stream.get_final_message()

The system parameter is a top-level field, not a message with role: "system". Passing it as a list of content blocks is what lets you attach a cache_control breakpoint to it, which is the single highest-value optimisation on this page.

Tool use is the same request with a tools array. Claude returns a tool_use block, you execute the function yourself and send the result back as a tool_result block in the next user turn. Anthropic also runs a set of server tools on its own infrastructure, so no loop of yours is involved. Practical patterns for both, including forcing a single tool to get JSON out, are in the production guide, and prompt-side technique is on the prompt engineering page.

#How much does prompt caching actually save?

Prompt caching stores a prefix of your request server-side. A write costs 1.25× base input for a five-minute TTL or 2× for a one-hour TTL; a read costs 0.1×. Reads refresh the TTL, so a steadily used cache stays warm on one write. The break-even is published plainly: one read pays back a five-minute write, two reads pay back a one-hour write.

OperationMultiplier on base inputOn Sonnet 5 ($2 base)
Ordinary input token$2.00 / MTok
Cache write, 5-minute TTL1.25×$2.50 / MTok
Cache write, 1-hour TTL$4.00 / MTok
Cache read (hit or refresh)0.1×$0.20 / MTok

A worked example. A support-triage service sends a 20,000-token system prompt - policy documents, tone rules, a taxonomy - with every request, and handles 1,000 requests in an hour on Sonnet 5.

  • No caching: 1,000 × 20,000 tokens = 20M input tokens at $2 = $40.00.
  • With a five-minute cache: one write of 20,000 tokens at $2.50/MTok = $0.05, then 999 reads at $0.20/MTok = $4.00. Total $4.05.

That is a 90% cut on the cached portion, and it scales with prefix length rather than with cleverness. Two constraints decide whether it fires at all. The prefix must be long enough to be cacheable - the minimum is 512 tokens on Opus 5 and Fable 5, 1,024 on Sonnet 5 and Haiku 4.5, and 4,096 on Opus 4.6 and Opus 4.5 - and the prefix must be byte-identical each time. A timestamp, a request ID or a user's name near the top of the system prompt invalidates every cache hit downstream of it. Put volatile content last.

You may set up to four explicit breakpoints per request, each with a 20-block lookback. Automatic caching, enabled with one top-level field, consumes one of the four slots and lets Anthropic pick the boundaries.

#When should you use the Batch API?

Anything without a human waiting on it. Batch usage is charged at a flat 50% of standard rates on input, output and special tokens, and the discount stacks with caching multipliers - so a cached batch read on Sonnet 5 costs $0.10 per MTok.

PropertyValue
DiscountFlat 50% on all token categories
Batch size100,000 requests or 256 MB, whichever comes first
Completion windowResults available when all requests finish, or after 24 hours
ExpiryRequests not completed within 24 hours expire and are not billed
Result retention29 days from batch creation
Model supportAll active models
Not supportedstream, fast mode, max_tokens: 0

Most batches finish well inside an hour, but you cannot rely on it - design the consumer to poll. Because a batch can outlive a five-minute cache, Anthropic's own advice is to use the one-hour TTL for cached prefixes inside batch jobs. For very long single generations, the output-300k-2026-03-24 beta header raises the batch max_tokens ceiling to 300,000 on Opus 5, 4.8, 4.7 and 4.6 and on Sonnet 5 and Sonnet 4.6; a single 300k-token generation can take over an hour on its own. An end-to-end overnight batch script is in the Sonnet 5 production guide.

#What server tools and agent APIs are available?

Server tools run on Anthropic's infrastructure. You declare them, Claude calls them, and the results come back inside the same response - there is no loop for you to write.

ToolStatusCost beyond tokens
Web searchGA$10 per 1,000 searches; failed searches are not billed
Web fetchGANone
Code executionGAFree when paired with web search or web fetch; otherwise 1,550 free container-hours per month per organisation, then $0.05/hour
Computer useGA since 19 Aug 2026Toolset definition adds roughly 4,500 input tokens per request
Browser useLaunched 19 Aug 2026Toolset definition adds roughly 6,600 input tokens per request

Computer use no longer needs a beta header, and the browser use tool shipped alongside it on the same day. Both are available on Fable 5, Opus 5, Sonnet 5 and Opus 4.8. Note that a tool definition is input you pay for on every turn, so a large toolset is a recurring cost, not a one-off.

#Managed Agents

Public beta Managed Agents is a hosted agent harness - Anthropic runs the loop, the sandbox and the session state, so you call a REST API instead of writing an agent framework. Requests need the managed-agents-2026-04-01 beta header, which the SDKs set for you. Billing is standard token rates plus $0.08 per session-hour, metered to the millisecond and accruing only while a session's status is running; idle, rescheduling and terminated time is free, and session runtime replaces code-execution container billing rather than adding to it.

Compliance limitation

Managed Agents sessions are stateful by design and store conversation history, sandbox state and outputs server-side. They are not eligible for zero data retention or HIPAA BAA coverage. If your workload is covered by either, build the loop yourself on /v1/messages. Regulated-industry controls are summarised on the enterprise page.

#The MCP connector

The Model Context Protocol connector lets the API call remote MCP servers directly, without you proxying the tools. It is still beta, behind the mcp-client-2025-11-20 header, and it is tools-only - the rest of the MCP specification is not implemented. Servers must be publicly reachable over HTTPS, so a local STDIO server cannot be attached. It is not available on Amazon Bedrock or Google Cloud, and it is not ZDR-eligible. Architecture patterns, including when to run your own client instead, are on MCP and Claude agents; scheduling and orchestration sit on the automation page.

#How do Claude API rate limits work?

Organisations sit on a named tier - Evaluation, Start, Build, Scale or Custom - assigned automatically from usage history and account standing. They are not "Tier 1 to 4", and you do not choose your own. Each tier sets requests per minute, input tokens per minute (ITPM) and output tokens per minute (OTPM) per model bucket, plus a monthly spend cap: $500 on Start, $1,000 on Build, $200,000 on Scale, and none on Custom.

Model bucketStart (RPM / ITPM / OTPM)BuildScale
Fable 51,000 / 500,000 / 100,0002,000 / 1.5M / 300,0004,000 / 4M / 800,000
Opus 51,000 / 2,000,000 / 400,0005,000 / 5M / 1M10,000 / 10M / 2M
Sonnet 51,000 / 2,000,000 / 400,0005,000 / 5M / 1M10,000 / 10M / 2M
Haiku 4.51,000 / 2,000,000 / 400,0005,000 / 5M / 1M10,000 / 10M / 2M

Two details change how you design around this. First, Fable 5's limits are materially tighter than Opus 5's - a quarter of the input throughput at Start tier - so a Fable 5 agent fleet hits a ceiling long before an Opus 5 one does. Second, cache reads do not count toward ITPM on any current model; only fresh input tokens and cache-creation tokens do. Caching therefore buys you headroom as well as money, which is often the reason to adopt it first.

Opus 4.8, 4.7, 4.6 and 4.5 share one combined bucket; Opus 5 has its own. Limits are enforced with a token bucket, so a sharp ramp can trigger a 429 even below your nominal ceiling. Responses carry retry-after and a family of anthropic-ratelimit-* headers - honour them rather than guessing. Hitting the spend cap is different: it returns a 429 with error code enforced_spend_limit_reached and no retry-after, because waiting will not help.

#Can you run Claude on AWS, Google Cloud or Microsoft Foundry?

Yes, on all three, with different model identifiers. This is usually a procurement and data-residency decision rather than a technical one - the request shape is the same, but a few first-party features do not travel.

PlatformOpus 5Sonnet 5Fable 5Haiku 4.5
Claude APIclaude-opus-5claude-sonnet-5claude-fable-5claude-haiku-4-5
AWS Bedrockanthropic.claude-opus-5anthropic.claude-sonnet-5anthropic.claude-fable-5anthropic.claude-haiku-4-5-20251001-v1:0
Google Cloud Vertex AIclaude-opus-5claude-sonnet-5claude-fable-5claude-haiku-4-5@20251001
Microsoft FoundryAvailable; Foundry is supported by the C#, Java, PHP, Python and TypeScript SDKs only

What you give up on the resellers: the MCP connector is unavailable on Bedrock and Google Cloud, web search is unavailable on Bedrock and basic-only on Google Cloud, the Files API is unavailable on both, and fast mode is first-party only. Regional and multi-region endpoints on Bedrock and Google Cloud carry a 10% premium over global endpoints. Bedrock and Foundry also bill through marketplace Claude Consumption Units at $0.01 per CCU rather than in dollars per token.

If you are choosing a model rather than a platform, start at the model index; if you are choosing between an API key and a subscription, the pricing page compares them directly.

#Frequently asked questions

How much does the Claude API cost per million tokens?

As of August 2026: Fable 5 is $10 input and $50 output per million tokens, Opus 5 is $5 and $25, Sonnet 5 is $2 and $10, and Haiku 4.5 is $1 and $5. Cache reads cost 0.1 times base input, and Batch API usage is a flat 50% off.

Why does passing temperature return a 400 error?

Because temperature, top_p and top_k were removed on Opus 4.7 and later and on Sonnet 5. Passing a non-default value returns HTTP 400. Reasoning depth is now controlled by the effort parameter instead, and structured output should be obtained through tool use rather than sampling settings.

Do I need a beta header for the 1M-token context window?

No. On Fable 5, Opus 5 and Sonnet 5 the 1M-token window is the default and the maximum, with no beta header and no long-context price premium. A 900,000-token request bills at the same per-token rate as a 9,000-token one. Haiku 4.5 remains at 200,000 tokens.

Does a Claude Pro subscription include API credit?

No. Console API billing and claude.ai subscriptions are entirely separate. A Pro or Max plan covers the apps and Claude Code but gives you no API tokens, and an API key gives you no subscription features. Organisations that need both buy both.

What is the fastest way to cut a Claude API bill?

Cache the stable prefix of your prompt and move deferrable work to the Batch API. Caching drops repeated input to 0.1 times base price and does not count toward input-token rate limits; batching takes a flat 50% off. Dropping to a smaller model is the third lever.

Which rate-limit tier am I on?

Tiers are named Evaluation, Start, Build, Scale and Custom, and Anthropic assigns them automatically from your usage history and account standing. Your current limits are visible in the Console and readable programmatically through the Rate Limits API and the anthropic-ratelimit response headers.

Verify it yourself

Model IDs, parameters and limits checked against platform.claude.com/docs, and rates against claude.com/pricing, on 21 August 2026. Anthropic changes prices, beta headers and rate limits without notice - re-check both before you commit to an architecture or a budget.