Anthropic API Guide: Claude Models, Pricing and Setup

Anthropic API Guide: Claude Models, Pricing and Setup

This Anthropic API guide explains how to call Claude from your own code, which model to pick and what it will cost. The Anthropic API is a pay-per-use service that gives applications programmatic access to the Claude family of models through a REST interface. The central question is how to start building with it safely, and the short answer is to use the Messages API with Claude Sonnet 5.5, pay per token, and add prompt caching before you optimise anything else.

Claude is a family of large language models built by Anthropic, and the API is separate from the Claude chat subscription. A Claude Pro or Team subscription does not include API credits: developer access is set up in the Claude Console and billed separately by usage. That separation matters for budgeting, because the API bill grows with every token your application sends and receives.

Key takeaways

  • This Anthropic API guide covers the Messages API, the current Claude models, token pricing and the cost-saving features that matter most.
  • The main endpoint is the Messages API, a stateless REST interface reached with a POST request to the messages endpoint.
  • Claude Opus 5.5 is the recommended default for most workloads, Claude Sonnet 5.5 balances speed and intelligence, and Claude Haiku 5.5 is the cheapest option for high-volume work.
  • Pricing is per million tokens, and prompt caching plus the Batch API can cut that bill substantially.
  • Every request needs an API key and a version header, and usage is controlled through the Claude Console.

What the Anthropic API is

The Anthropic API is a REST API hosted at the Anthropic API domain, and it is the programmatic way to use Claude. Your application sends a request containing a model name, a list of messages, system instructions and parameters such as the maximum output length, and Claude returns the next response. The same interface supports text and image input, tool use, structured outputs and extended thinking, so one endpoint covers most use cases.

The API is stateless, which means it remembers nothing between requests. Your application must send the conversation history with each call if it wants Claude to remember what was said. That design keeps the interface simple, but it also means long conversations grow expensive, because the full history is re-sent and re-billed on every turn.

Best for: teams building chat, coding assistants, document processing or agent features directly into their own products.

The Messages API: the core endpoint

The Messages API is the primary interface, and a minimal request is a POST to the messages endpoint with three things: a model identifier, a list of messages and a maximum token count for the response. Requests also need an API key in the header and an Anthropic version header, which Anthropic sets to a dated value. The API returns the response text, the number of input and output tokens used, and a stop reason explaining why generation ended.

Unlike some chat APIs, the Messages API has no system role inside the messages array. System instructions go in a separate top-level field, which keeps the prompt structure clean. The API also supports streaming, so a chat interface can show words as they are generated instead of waiting for the full reply.

For the architecture around the endpoint, see our guide to LLM API architecture, which explains how requests, tokens and tools fit together. Best for: direct model access where you control the conversation loop, the prompts and the retry logic yourself.

Claude models and pricing

Anthropic sells four current Claude models, all with a one million token context window and a maximum output of 128,000 tokens per synchronous request. Claude Fable 5.1 is the most capable model, built for demanding reasoning and long-horizon agentic work, at $10 per million input tokens and $50 per million output tokens. Claude Opus 5.5 is Anthropic’s recommended default for coding agents and knowledge work, at $4 per million input tokens and $20 per million output tokens.

Claude Sonnet 5.5 balances speed and intelligence at $2 per million input tokens and $10 per million output tokens, and it is the workhorse for most production applications. Claude Haiku 5.5 is the fastest and cheapest, starting at $0.10 per million input tokens and $0.50 per million output tokens for shorter prompts, with higher rates for prompts above 100,000 tokens. All four support text and image input, vision and tool use.

Prices change, so check Anthropic’s official pricing page before budgeting a production workload, and see our LLM inference pricing comparison for how token costs add up in practice.

Comparing the Claude models

Model Input per 1M tokens Output per 1M tokens Context window Best for
Claude Fable 5.1 $10 $50 1M tokens Demanding reasoning, long agentic work
Claude Opus 5.5 $4 $20 1M tokens Coding agents, knowledge work
Claude Sonnet 5.5 $2 $10 1M tokens Balanced speed and intelligence
Claude Haiku 5.5 From $0.10 From $0.50 1M tokens High-volume, latency-sensitive tasks

The table shows that the price spread between the cheapest and most expensive model is a hundredfold on input tokens, which is why model choice is the single biggest cost decision. Start with Sonnet 5.5, move up to Opus 5.5 only where the quality difference is visible in your own tests, and move down to Haiku 5.5 for classification, routing and extraction. For a framework that makes that choice systematically, see our guide to LLM model routing.

Hands typing on a laptop keyboard beside a steaming cup of coffee on a wooden desk
Most Anthropic API work starts in a console and a terminal: a key, a request and a first response, before any framework is added.

Prompt caching and the Batch API

Prompt caching is the cheapest win in the Anthropic API. When the same system prompt or document is sent repeatedly, cached input is billed at a small fraction of the normal input price, and cache reads on Opus 5.5 and Sonnet 5.5 cost only a small percentage of the base input rate. That matters for applications that send the same instructions with every request, such as a support assistant with a long policy document or a coding agent with a large codebase context.

The Batch API cuts prices by half across every model for work that does not need an immediate answer. A batch job is submitted as a set of requests and processed asynchronously, which suits overnight evaluation, bulk classification and document processing. Between caching and batching, most teams can cut their token bill by a third or more without changing models.

Track the effect with usage monitoring; our guide to tracking LLM token usage shows how to measure and control API spend. Best for: any production application where the same prompt is sent often, or where answers can wait for a batch run.

Tool use, thinking and structured outputs

Tool use lets Claude call functions your application defines, such as searching a database, fetching a file or running a calculation. Your application sends tool definitions with the request, Claude returns a tool call, your code executes it, and the result is sent back for the next step. That loop is the foundation of most Claude agents, and it works best when each tool does one clear job and returns short, structured results.

Extended thinking gives Claude space to reason before answering, which improves accuracy on hard problems at the cost of more output tokens. Structured outputs constrain the response to a defined shape, which is useful when the result feeds another system rather than a human reader. Together these features turn the Messages API from a chatbot endpoint into a building block for agents, and they pair naturally with the Model Context Protocol, which standardises how AI applications connect to tools.

Best for: agents and automations where Claude must act, not just answer.

Setting up: a decision framework

Set up in four steps. First, create an account in the Claude Console, generate an API key and set a monthly spend limit so a bug cannot run up an unbounded bill. Second, send a test request to Sonnet 5.5 with a short prompt and confirm the response, the token counts and the billing record.

Third, add prompt caching for any repeated instructions and set up logging of every request, because an API without logs is impossible to debug or cost. Fourth, move to production with retries, timeouts and rate-limit handling, since the API enforces limits that vary by usage tier.

Rate limits rise as your account history and spend grow, and Anthropic publishes usage tiers that unlock higher throughput. Build for the tier you have, not the tier you expect, and add a queue or a fallback model for traffic spikes. Claude is also available through Amazon Bedrock, Google Cloud Vertex AI and Microsoft Foundry, which suits teams that already buy cloud services through those channels.

For the security side, see our LLM API security guide before exposing any endpoint to users.

Anthropic API checklist

  • API key is stored as a secret, never in source code or a client-side app.
  • A monthly spend limit is set in the Claude Console before the first production call.
  • The starting model is Claude Sonnet 5.5, with Opus 5.5 reserved for work that proves it needs more capability.
  • Prompt caching is enabled for repeated system prompts and documents.
  • Bulk work that can wait uses the Batch API at half price.
  • Every request is logged with its token counts, so cost and quality can be traced.
  • Retries, timeouts and rate-limit handling are in place before launch.

Frequently asked questions

Does a Claude subscription include API access?

No. The Anthropic API is a separate product billed by token usage, and a Claude Pro, Team or Enterprise subscription does not include API credits. Developer access is configured through the Claude Console and paid for separately.

Which Claude model should I start with?

Start with Claude Sonnet 5.5. It balances speed, intelligence and price for most production work, and Anthropic recommends Opus 5.5 as the default for coding agents and knowledge work. Move up to Opus 5.5 or Fable 5.1 only when your own tests show a quality gap, and move down to Haiku 5.5 for high-volume, latency-sensitive tasks.

How much does the Anthropic API cost?

It charges per token, with no monthly fee. Input prices run from $0.10 per million tokens on Claude Haiku 5.5 to $10 on Claude Fable 5.1, and output prices run from $0.50 to $50 per million tokens. Prompt caching and the Batch API, which halves prices, can reduce the bill substantially.

What is the context window for Claude models?

All four current Claude models have a one million token context window, which Anthropic describes as roughly 555,000 words, and a maximum output of 128,000 tokens per synchronous request. Long prompts cost more, so caching and careful context management matter at scale.

Can I use the Anthropic API through my cloud provider?

Yes. Claude is available through Amazon Bedrock, Google Cloud Vertex AI and Microsoft Foundry, each with its own billing and authentication. That suits teams that already manage cloud spend through one of those platforms, though the direct API through the Claude Console is the simplest starting point.

Latest articles

Scroll to Top