Anthropic API

Build with Claude — large context windows, tool use, and strong reasoning.

Developer API

Overview

The Anthropic API is the developer-facing surface for Claude — the same Sonnet 4.5 and Opus 4.7 models that power claude.ai, exposed as HTTPS endpoints with per-token pricing, first-party SDKs, native tool use, prompt caching, a 1M-token context window on Sonnet, and the Model Context Protocol as a first-class extension mechanism. If you have shipped code that had to be reviewed by a careful human, or prose that had to survive an editor, there is a good chance the second API key in your .env file starts with sk-ant-.

Anthropic launched the API before it launched the consumer product — Claude was available to developers via the API for months before claude.ai became a real destination — and that heritage still shapes the platform. Pricing is transparent, versioning is disciplined, deprecations are announced far in advance, and the SDK surface is deliberately small enough to memorize. The whole thing feels engineered by people who ship production systems, because it was.

The one-line positioning: the Anthropic API is the pick when the quality of a single response matters more than the last 10% of price optimization — the model that wins SWE-bench Verified, wins long-form writing tasks, and holds an entire codebase in memory without pretending to. It is not always the cheapest per token and not always the fastest per request, but for the calls where output quality matters, it delivers a measurable advantage that shows up in production metrics.

Under the hood, the API surface splits into three model families (Sonnet, Opus, Haiku), a mature tool-use system, native prompt caching, computer-use skills, a Batch API at 50% off, and an MCP integration layer that lets Claude call arbitrary external systems as first-class tools. Learn the Messages API surface — one endpoint, roughly a dozen parameters — and every other capability becomes a variant of the same request shape.

Key Features

The Anthropic API's feature set in 2026 is more focused than OpenAI's but deeper on the things it does ship:

  • Claude Sonnet 4.5 as the workhorse. The frontier model most production traffic should route to. Tops SWE-bench Verified on real GitHub issues, wins long-form writing evaluations against GPT-5 and Gemini 2.5 Pro, and holds a 1M-token context window on the API. Streaming latency is competitive with GPT-5 flagship.
  • Claude Opus 4.7 for the hard calls. The slower, more deliberate model — Anthropic's frontier reasoning tier, comparable in latency to OpenAI's o3 but with a broader capability profile. Reserve Opus for the calls where a wrong answer costs more than the extra token spend.
  • Claude Haiku 4 for high-volume low-stakes work. The classifier-cheap tier — fast, cheap, and good enough for extraction, routing, moderation, and light summarization. Roughly the analogue of GPT-5 mini or GPT-5 nano, priced competitively with both.
  • 1M-token context window on Sonnet. Not a marketing number — the model actually uses it well, with strong retrieval quality across the full window. This alone changes how RAG and long-document analysis get architected: you can often skip retrieval entirely and pass the whole corpus, letting the model do the finding.
  • Native tool use with parallel calls. Define tools with JSON Schema, get structured tool_use blocks back, execute your side, and continue. Parallel tool calls are supported natively, so agents that want to fetch three things concurrently do not need to serialize.
  • Prompt caching with 90% discount on cache hits. Cache system prompts, tool definitions, or long stable prefixes and pay 10% of the input token price on subsequent reads. For any RAG or agent workload with a stable system prompt, this is the single largest cost lever the API offers — and it is a one-line change.
  • Computer Use. Give Claude a virtual desktop over a screenshot-plus-actions loop and it drives applications the way a human does. In 2026, computer use works reliably for structured web workflows and remains best-in-class for the assistant-driving-a-browser use case.
  • MCP as a first-class extension mechanism. The Model Context Protocol, authored by Anthropic and now supported by all major clients, lets you attach servers exposing Postgres, GitHub, Sentry, filesystem, or any custom tool to Claude with judgment about when to call each. This is the deepest tool-use ecosystem of any frontier API.
  • Extended thinking on Opus and Sonnet. Enable a longer internal reasoning phase before the final answer — trade seconds of latency for measurably better output on hard math, code, and planning tasks. You control the thinking budget per request.
  • Batch API at 50% off. Submit a JSONL of requests, get results within 24 hours, pay half. Same pattern as OpenAI's Batch, priced identically as a discount.
  • SDKs in Python, TypeScript, Java, Go, and Ruby. First-party, versioned in lockstep with the API. The Python and TypeScript SDKs are the most feature-complete, with helpers for streaming, tool use, and Vertex/Bedrock deployments.

Pricing

Anthropic API pricing is per token, tiered by model, with prompt caching and Batch API as the main cost levers. Approximate per-million-token prices in mid-2026:

Model Input ($/M) Output ($/M) Cached read ($/M)
Claude Opus 4.7 $15.00 $75.00 $1.50
Claude Sonnet 4.5 $3.00 $15.00 $0.30
Claude Haiku 4 $0.25 $1.25 $0.025

Prompt caching writes cost 25% more than base input tokens; cache reads cost 10% of base input. Cache TTL is 5 minutes by default with a 1-hour extended TTL available at additional cost. Batch API is a flat 50% discount off sync-endpoint prices. Computer use bills as normal token usage for the screenshots and tool_use blocks — there is no per-action surcharge.

The pricing that actually matters for most projects: Sonnet 4.5 at $3/$15 with prompt caching enabled is the sweet spot for production traffic. Cache your system prompt and tool definitions and effective input costs drop to $0.30/M — cheaper than GPT-5 mini on the cache-hit path. Reserve Opus for the calls where SWE-bench-tier reasoning is worth the 5x price bump, and route classification, extraction, and moderation to Haiku.

The 90%-discount cache is the biggest architectural lever the platform offers, and it is under-used. A well-designed agent with a stable system prompt and cached tool definitions will spend most of its input token bill at cache-read rates, which changes the economics of long-context work substantially.

Pros and Cons

Pros

  • Top-of-benchmark coding on hard problems — Sonnet 4.5 leads SWE-bench Verified in mid-2026
  • 1M-token context on Sonnet actually works well across the full window, not just in the first 200K
  • Prompt caching at 90% discount is the deepest cost-optimization lever in the frontier-API market
  • Native MCP support opens the door to production tool ecosystems that other providers require you to hand-roll
  • The Messages API surface is small enough to fully understand — no sprawling assistant/thread/run abstractions to work around
  • Computer Use is production-ready for structured web workflows
  • The model pushes back on bad plans and ambiguous requests in a way that shows up in agent quality

Cons

  • No native image generation — Claude will help you write prompts for DALL-E or Midjourney, not render pixels
  • No native audio input/output — pair with Whisper or Deepgram for STT and ElevenLabs for TTS
  • No first-party embeddings model — use Voyage AI (recommended by Anthropic), OpenAI, or Cohere
  • Opus token pricing is genuinely expensive at $15/$75 — must be reserved for the calls that need it
  • Rate limits on new accounts are conservative; you have to accumulate billing history to unlock higher tiers
  • Smaller SDK language coverage than OpenAI — .NET, Kotlin, and PHP developers rely on community SDKs

Best Use Cases

  • Coding agents and IDE integrations. SWE-bench Verified leadership translates to real production quality on refactors, migrations, bug fixes, and code review. Cursor, Zed, and Claude Code all default to Sonnet for a reason.
  • Long-document analysis and legal/research work. The 1M-token context lets you paste an entire contract, an annual report, or a research corpus and reason across the whole thing without chunking. RAG stops being mandatory below a certain document scale.
  • Content-quality-sensitive writing pipelines. Editorial workflows, marketing copy at scale, technical documentation. Sonnet's writing voice needs less editorial cleanup than GPT-5's, and that difference compounds over the volume.
  • Production agentic systems with tool use. Native MCP support, parallel tool calls, and Claude's judgment about when to call which tool make it the pick for agents that have to survive real-world edge cases. The tool-use ergonomics are the best in the category.
  • Prompt-cache-heavy RAG systems. Any RAG stack with a stable system prompt and set of tool definitions becomes 3-5x cheaper on the input path with caching enabled. This is the workload where Anthropic's pricing quietly beats OpenAI.
  • Computer-use automation. For assistants that need to drive a browser or a virtual desktop, Claude is the frontier model with the most mature product-ready surface.

Alternatives

The Anthropic API's competitors sit inside the same tier of frontier providers and a few open-model hosts:

  • OpenAI API — GPT-5 family, wider product surface (images, voice, Realtime), the Responses API for agentic work. Pick this if you need images, audio, or the deepest general-purpose model catalog.
  • Groq — open-weight models at 500+ tokens/sec via LPU hardware. Pick this if latency dominates your UX and open-weight quality is enough for your workload.
  • Together AI — cost-optimized hosting of Llama, DeepSeek, and Qwen with fine-tuning. Roughly one-third the token price of Sonnet for open-weight quality tiers.
  • Hugging Face — inference endpoints and the model hub. Pick this if you need a specific open-weight model or want dedicated fine-tuned deployments.
  • AWS Bedrock and GCP Vertex AI — the same Claude models, hosted by the hyperscalers with enterprise compliance, regional deployments, and BAA/HIPAA. Pick this if procurement requires AWS or GCP.

For the consumer product on top of this API, see Claude. For head-to-head against ChatGPT and Gemini, read ChatGPT vs Claude vs Gemini: The Definitive 2026 AI Assistant Comparison.

Getting Started

  1. Create an account at console.anthropic.com and generate an API key. New accounts get $5 in free credits, enough to run a few million tokens through Haiku or Sonnet and evaluate quality on your actual workload.
  2. Install the official SDK. pip install anthropic for Python, npm install @anthropic-ai/sdk for TypeScript. The Messages API quickstart in the docs gets you a first response in five lines of code.
  3. Route production traffic to Sonnet 4.5 with prompt caching enabled. Structure your requests so the stable system prompt and tool definitions come first, mark the cache_control breakpoint, and let the platform do the rest. This one-line change often cuts input costs by 60-80% at steady state.

Enable Workspaces for spend attribution across projects, set per-key rate limits before you hand keys to teammates, and use the Batch API for anything that doesn't need to be synchronous. For agentic workloads, wire in MCP servers early — the ergonomic gain over hand-rolling tool schemas is real.

FAQ

Is the Anthropic API the same models as Claude.ai? Yes. Sonnet 4.5 and Opus 4.7 are the same models on both surfaces. The consumer product adds product-layer features (Projects, Artifacts, Memory) that are not part of the raw API. The underlying model responses are identical for identical prompts.

How much does Sonnet 4.5 cost per real conversation? A typical multi-turn support conversation of ~5,000 input tokens and 500 output tokens costs about $0.023 on Sonnet uncached, $0.009 with prompt caching enabled, and $0.0018 on Haiku. The caching path is often cheaper than GPT-5 mini for equivalent workloads.

Does Anthropic train on my API traffic? No. API traffic is not used to train models by default. This is different from Claude Free and Claude Pro, where consumer chats may be used for training unless you opt out. Team and Enterprise consumer plans also opt out of training by default.

What's the largest context window? 1 million tokens on Sonnet 4.5 for API users, 200K on Opus 4.7, and 200K on Haiku 4. The 1M window on Sonnet is the largest usable context in the frontier-API market as of mid-2026, and retrieval quality across the window is genuinely good.

Can I fine-tune Claude? Fine-tuning is available on Haiku via AWS Bedrock. Sonnet and Opus are not fine-tunable directly. Anthropic's stance is that prompt engineering plus structured outputs and tool use get you further than fine-tuning for the vast majority of use cases, and in practice this holds up.

Verdict

The Anthropic API is the frontier LLM platform most technical teams end up defaulting to once they have measured quality on their own workloads. The combination of Sonnet 4.5's coding and writing quality, 1M-token context, native tool use with MCP, and prompt caching at 90% discount adds up to a platform that quietly delivers better results per dollar than the competition on the workloads where output quality matters.

Where the Anthropic API stops being the obvious choice is on the axes it deliberately doesn't optimize for: no native image generation, no native audio, no first-party embeddings, and a smaller total product surface than OpenAI. Teams building multimodal products, voice interfaces, or image-heavy workflows will need to pair Anthropic with other providers or start elsewhere.

The honest recommendation for most teams shipping code or content in 2026: start on Sonnet 4.5 with prompt caching enabled, keep Haiku in reserve for high-volume low-stakes calls, and pull Opus in only for the calls where the extra reasoning is worth 5x the price. Multi-provider strategies are common in mature stacks — Anthropic for the writing-quality and coding calls, OpenAI for the image and voice work, Groq or Together for the latency-sensitive open-weight tier. Almost every serious AI product in 2026 uses at least two of these, and Anthropic usually earns its slot on quality, not marketing.

Explore more in the Developer API category, or read The Economics of AI Inference at Scale for the broader token-pricing landscape.