Schuyler Stacy2026-02-03

Claude AI API Guide: Models, API Keys, Pricing, and Code

Compare Claude API models and pricing, get an API key, and send requests through Anthropic or GPTProto with Python and cURL examples.

Claude AI API Guide: Models, API Keys, Pricing, and Code

Sending one request to Claude is easy. The harder part is choosing the right model, getting the correct API key, and parsing the response without mixing two different API formats.

Yes, Claude has an API. You can access it directly through Anthropic’s Messages API or use a provider such as GPTProto, which exposes supported Claude models through an OpenAI-compatible endpoint. Those routes use different keys, request formats, and response objects. Treating them as interchangeable is where otherwise reasonable code starts to fail.

This guide connects the pieces: what the Claude AI API is, which model fits each workload, what a request costs, and how to call Claude through either route.

Last verified: September 17, 2026. Model availability and prices can change, so recheck the linked model pages before deploying.

Table of contents

What Is the Claude AI API?

The Claude AI API is a programmatic interface that lets an application send messages or supported content to a Claude model and receive a structured response. A customer-support system can use it to classify tickets, a coding agent can ask it to inspect a repository, and a document workflow can send text or supported files for analysis.

When you access Claude directly, the main interface is Anthropic’s POST /v1/messages endpoint. A conversation is stateless at the API level: if your application needs earlier messages, it sends the relevant history again with the next request. Anthropic also provides APIs for Message Batches, Token Counting, Models, Files, and Skills, but Messages is the place to start for a standard text interaction.

The Claude chat product and Claude API are separate billing surfaces. Paying for a consumer Claude subscription should not be treated as API credit, and creating an API key does not create a separate per-key charge. API cost comes from usage.

Claude API Models Compared: Fable, Opus, Sonnet, and Haiku

The current Claude family has four practical tiers. Their names signal different capability, speed, and cost targets, but the safest choice still comes from testing your own prompts.

Model Exact API model ID Context / max output Relative speed Best starting use
Claude Fable 5.1 claude-fable-5-1 1M / 128K Slower Hardest reasoning and long-horizon agents after Opus falls short
Claude Opus 5 claude-opus-5 1M / 128K Moderate Capability-first evaluation, complex coding, and enterprise agents
Claude Sonnet 5 claude-sonnet-5 1M / 128K Fast Everyday coding, analysis, content, and tool use
Claude Haiku 4.5 claude-haiku-4-5-20251001 200K / 64K Fastest High-volume, latency-sensitive, and cost-sensitive work

The factual recommendation in Anthropic’s model-selection documentation is to start with Opus 5 for most capability-first workloads. Fable 5.1 is the next step when Opus at higher effort still fails the evaluation. That is a meaningful change from older guides that treated Sonnet as the automatic default.

My practical recommendation is narrower. If answer quality is the first constraint, begin your evaluation with Opus 5. If you are designing a cost-aware production service, test Sonnet 5 against the same evaluation set before committing. Haiku 4.5 belongs in routing, extraction, classification, and other high-volume paths where speed and price matter more than handling the hardest reasoning case. Fable 5.1 should be an escalation tier. Its higher capability target comes with the highest price and slower relative latency.

One naming detail is easy to miss: a dateless model ID is not necessarily an alias that changes underneath your application. Anthropic states that, from Claude 4.6 onward, dateless IDs identify pinned snapshots. Record the exact ID you tested, even when it does not contain a date.

Which Claude AI API Provider Should You Use?

Choosing a Claude AI API provider is partly a product decision and partly an integration decision. Direct Anthropic access gives you the native Messages API. GPT Proto gives you an OpenAI-compatible chat-completions contract across supported models.

Decision point Direct Anthropic API GPT Proto route
Authentication Anthropic key and official SDK One GPT Proto bearer key
Request contract Anthropic Messages API OpenAI-compatible /v1/chat/completions
Price basis Anthropic’s official list price Current Claude collection lists rates 10% below the official rates
Model switching Claude family One key and prepaid balance across supported models and providers
Feature access Upstream source of truth Route support can differ or arrive later

Use Anthropic directly when native response semantics and access to the latest upstream features matter most. Use GPT Proto when an OpenAI-compatible integration, one balance across multiple model providers, or the current lower listed token rates are more valuable.

There is a cost to that convenience: route support is not guaranteed to match every upstream modality, beta header, tool feature, or response field. Check the individual route before designing around it. You can compare the Claude models currently available through GPT Proto before choosing an integration.

Claude AI API Pricing: What Does One Request Cost?

Claude AI API pricing is based mainly on input and output tokens, not on the API key itself. The table below compares Anthropic’s current list prices with the prices displayed in GPT Proto’s Claude collection. Rates are in US dollars per 1 million tokens.

Model Anthropic input / output GPT Proto input / output
Claude Fable 5.1 $10 / $50 $9 / $45
Claude Opus 5 $5 / $25 $4.50 / $22.50
Claude Sonnet 5 $2 / $10 $1.80 / $9
Claude Haiku 4.5 $1 / $5 $0.90 / $4.50

Per-million-token pricing is hard to interpret until it becomes a request. Suppose one API call sends 10,000 input tokens and receives 2,000 output tokens:

request cost = (input tokens ÷ 1,000,000 × input rate) + (output tokens ÷ 1,000,000 × output rate)

Model Anthropic cost for the request GPT Proto cost for the request
Fable 5.1 $0.200 $0.180
Opus 5 $0.100 $0.090
Sonnet 5 $0.040 $0.036
Haiku 4.5 $0.020 $0.018

The important cost lesson is not merely that Haiku is cheaper. Output tokens cost five times as much as input tokens across these four current rates. A verbose response policy can therefore matter as much as the model choice.

Anthropic’s Message Batches API reduces standard input and output token charges by 50%. Prompt caching follows a different calculation: a 5-minute cache write costs 1.25 times the base input rate, a 1-hour write costs twice the base input rate, and a normal cache read costs 0.1 times the input rate. Fable 5.1 cache reads use a lower 0.025 multiplier. These features help only when the workload actually reuses content or can wait for batch processing; adding them to a one-off request increases complexity without creating savings.

How to Get a Claude AI API Key

The correct key depends on the endpoint you plan to call. An Anthropic key belongs to Anthropic’s API. A GPT Proto key belongs to GPT Proto’s endpoint.

Option 1: Create an Anthropic API key

Open the Claude Console, then go to Settings → API keys. Create a key and choose the available name, expiration, linked account, and workspace settings. The full secret is displayed once and starts with sk-ant-, so copy it into a secure secrets store at creation time.

For local development, expose it to the official SDK through an environment variable:

export ANTHROPIC_API_KEY="your-anthropic-key"

Option 2: Create a GPT Proto API key

Create a key in the GPT Proto dashboard’s API Keys area, store it securely, and expose it as a separate variable:

export GPTPROTO_API_KEY="your-gptproto-key"

Requests to GPT Proto authenticate with Authorization: Bearer $GPTPROTO_API_KEY. The same key and prepaid balance can access the Claude models currently supported by GPT Proto, so you do not need a separate Anthropic key for that route.

Never commit either secret to Git, paste it into public logs, or ship it inside browser code. Keep model calls on the server or behind a service that can read environment variables or a secrets manager. If a key is exposed, revoke it rather than trying to hide the leak with another commit.

How to Use the Claude AI API

The two examples below solve the same task, but their contracts are different. Direct Anthropic code receives Anthropic content blocks. GPT Proto returns an OpenAI-style chat-completions object.

Send a request directly with Anthropic’s Python SDK

Install the official package:

python -m pip install anthropic

With ANTHROPIC_API_KEY set, send a request:

import anthropic

client = anthropic.Anthropic()

message = client.messages.create(
    model="claude-opus-5",
    max_tokens=1000,
    messages=[
        {
            "role": "user",
            "content": "Explain idempotency in one paragraph."
        }
    ],
)

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

message.content is a list of content blocks, so the example checks each block type before printing text. Do not assume the entire response is one plain string.

When you add a system instruction, place it in the top-level system parameter. Anthropic’s Messages API does not use a message with a system role. max_tokens is also a request-level parameter, capped by the selected model’s maximum output.

Send a Claude request through GPT Proto

GPT Proto uses an OpenAI-compatible endpoint and bearer authentication:

curl --request POST "https://gptproto.com/v1/chat/completions" \
  --header "Authorization: Bearer $GPTPROTO_API_KEY" \
  --header "Content-Type: application/json" \
  --data '{
    "model": "claude-sonnet-5",
    "messages": [
      {
        "role": "user",
        "content": "Explain idempotency in one paragraph."
      }
    ]
  }'

For a successful GPT Proto response, read the generated text from choices[0].message.content. Token accounting is returned in the usage object. Before copying this into production, confirm that claude-sonnet-5 is still listed on the Claude Sonnet 5 model page and run the request with your own key.

Do not mix the two request contracts

One tempting mistake is to put a GPT Proto key into anthropic.Anthropic(api_key=...) without configuring a compatible base URL. The Anthropic SDK then targets Anthropic’s default endpoint, where the GPT Proto key is invalid. The reverse mismatch is equally unhelpful: Anthropic’s content-block response parsing does not describe GPT Proto’s OpenAI-style object.

Pick one route, then keep its endpoint, key, payload, and response parser together.

Claude AI API Use Cases: Match the Model to the Workload

A model table is only a starting hypothesis. The final choice should come from a small evaluation set drawn from the work your application actually performs.

Workload Start with Why Trade-off
Classification, extraction, routing, and sub-agents Haiku 4.5 Lowest listed cost and fastest relative tier Less suitable for the hardest multi-step reasoning
Everyday coding, content, data analysis, and tool use Sonnet 5 Balanced price and capability Not Anthropic’s highest-capability option
Complex coding agents and higher-stakes enterprise work Opus 5 Anthropic’s capability-first default Official input and output rates are 2.5 times Sonnet 5 rates
Long-running research and the hardest reasoning Fable 5.1 Escalation tier when Opus still misses Highest price and slower relative tier

For many systems, the best design uses more than one model. Routine requests can go to Haiku or Sonnet. Cases that fail a validator, involve a higher-risk action, or require deeper reasoning can move to Opus. Fable sits above that path when an evaluation shows a real gain.

This worker-and-advisor pattern can reduce cost, but it adds routing logic and another failure mode. Log why a request was escalated and compare the final result against the cheaper model; otherwise, expensive routing tends to spread without evidence.

Upstream Claude models support text and image input, text output, tool use, and multilingual work. That does not prove that every capability is available through every provider route. Check the selected model page before promising image, document, or tool behavior to your users.

Before Production: Model IDs, Limits, Errors, and Cost Controls

A successful first request proves that authentication and payload shape work. It does not prove that an integration is ready for real traffic.

First, pin the exact model ID you evaluated. Current dateless Claude IDs can still refer to fixed snapshots. A model change should be deliberate: rerun the evaluation, compare cost and output behavior, and then update the production configuration.

Second, handle failure states by category rather than retrying everything:

Status Meaning What to do
400 Invalid request Validate parameters and message structure
401 Authentication error Check the key and environment variable
402 Billing error Check credits or billing setup
403 Permission error Check account and workspace access
404 Resource not found Check the endpoint and model ID
413 Request too large Reduce the request body
429 Rate or spend limit reached Back off and inspect current limits
500 Internal server error Retry safely
504 Gateway timeout Retry with safeguards against duplicate work
529 API overloaded Back off and retry

Anthropic’s SDKs retry rate-limit and transient 5xx failures twice by default with exponential backoff. That is useful, but it does not remove the need for application-level timeouts, request tracing, and duplicate-work protection.

Rate limits and spend limits are separate. Anthropic documents a 32 MB request limit for standard endpoints including Messages and Token Counting, 256 MB for Message Batches, and 500 MB for Files. A short burst can also hit a token-bucket limit even when the longer average looks acceptable.

At minimum, log the model ID, input tokens, output tokens, latency, request ID, error status, and estimated cost. These fields let you answer the production question that matters: did a more expensive model improve the result enough to justify its bill?

Pick the Route, Then Test the Model

Choose the access route first: direct Anthropic for native semantics and upstream features, or GPT Proto for an OpenAI-compatible contract, one cross-provider key, and currently lower listed Claude rates. Then test the least expensive model that can meet your quality requirement.

Haiku and Sonnet cover the efficiency end of the family. Opus is the capability-first starting point. Fable belongs at the top of an escalation path, not in every request. Before integrating, compare current Claude API availability and pricing on GPT Proto, then validate the chosen model with your own prompts.

Frequently Asked Questions

Does Claude AI have an API?

Yes. Anthropic exposes Claude through its Messages API at https://api.anthropic.com, along with related APIs for batching, token counting, models, files, and skills. GPTProto also provides access to supported Claude models through an OpenAI-compatible chat-completions endpoint.

Where can I find my Claude API key?

For direct Anthropic access, open the Claude Console and go to Settings → API keys. Create a key and copy it when the full value is shown. Store it as ANTHROPIC_API_KEY or in a secrets manager rather than hard-coding it.

Is a Claude API key free?

The key does not have a separate per-key price. API usage generates the charge based on model rates, token consumption, and any applicable features. Do not assume a fixed signup credit unless the current console explicitly offers one to your account.

Which Claude API model should I choose?

Start with Opus 5 when capability is the first priority, Sonnet 5 for a more cost-aware balance, and Haiku 4.5 for high-volume or latency-sensitive work. Move to Fable 5.1 only when your evaluation shows that Opus still misses the required result.

Is the Claude Sonnet API cheaper than the Claude Opus API?

Yes. The current official Sonnet 5 rates are $2 per million input tokens and $10 per million output tokens, compared with $5 and $25 for Opus 5. The trade-off is that Opus occupies the higher capability tier.

What is the Claude Fable API for?

Claude Fable 5.1 targets the hardest reasoning and long-horizon agentic work. It should usually be an escalation option rather than the first model used for every request because it has the highest listed token price and slower relative latency.

Does Claude Pro or Max include API usage?

Claude consumer subscriptions and API usage are separate products and billing surfaces. Check the Claude Console for API access and billing instead of assuming that a chat subscription includes API credits.

Can one GPTProto key access multiple Claude models?

Yes, one GPTProto key and prepaid balance can access the Claude models currently supported by GPTProto. Availability and route features can change, so check the Claude model collection before selecting an ID.

Related Articles

More Blogs
Anthropic API Guide: Claude Models, Pricing, and Which One Should You Choose?

Anthropic API Guide: Claude Models, Pricing, and Which One Should You Choose?

The Anthropic API gives developers programmatic access to Claude, but “Claude API” no longer means one model. As of August 21, 2026, the current family spans Claude Fable 5, Claude Opus 5, Claude Sonnet 5, and Claude Haiku 4.5. Each occupies a different point on the quality, speed, and cost curve. For most production applications, start with Claude Sonnet 5. Choose Haiku 4.5 when latency and request volume matter more than maximum reasoning quality. Move to Opus 5 for demanding coding and agentic work. Use Fable 5 only when your evaluations show that its extra capability justifies its higher price and data-retention requirement. Quick recommendation Most applications: Claude Sonnet 5 Fast, high-volume tasks: Claude Haiku 4.5 Complex coding and long-running agents: Claude Opus 5 The hardest capability-sensitive workloads: Claude Fable 5 Model availability and prices were checked on August 21, 2026. Always verify the live model page before deploying.

Michael Johnson | 2026-02-03

What Is Claude Opus 5.2? Release Status, Rumors, and What We Know

What Is Claude Opus 5.2? Release Status, Rumors, and What We Know

A model can answer differently without becoming a new model. That distinction matters here. Claude Opus 5.2 is the unconfirmed name attached to a possible next version of Anthropic’s Opus model. As of September 16, 2026, Anthropic has not published a release announcement, model card, API identifier, price, or benchmark results for Opus 5.2. Current reports come from Claude Code behavior tests and an unverified Microsoft Foundry slug—not an official launch. Claude Opus 5.2 status Current information Officially announced No Public beta Not confirmed API model ID Not available Pricing Not announced Verified benchmarks None Current official Opus model Claude Opus 5 Last checked September 16, 2026

Michael Johnson | 2026-09-16

6 Best Affordable LLM APIs for AI Agents in 2026

6 Best Affordable LLM APIs for AI Agents in 2026

An affordable LLM API for an AI agent is not necessarily the model with the lowest input-token price. An agent may choose a tool, construct arguments, read the result, revise its plan, and call another tool before it produces a useful answer. A cheap model that makes invalid calls or needs several retries can therefore cost more than a slightly more expensive model that finishes the task once. This guide compares six agent-ready models available through GPTProto. The ranking considers API price, tool use, independent performance evidence, speed, context limits, and the practical risk of paying for unnecessary agent loops. It is a public-benchmark and pricing comparison—not a claim that we ran a private head-to-head test. One Key for Your Team Quick answer: GLM-5.3 Flash is the strongest default for most cost-sensitive agents. DeepSeek Flash is the faster open-weight alternative, while GPT-5.6 Luna is promising for lightweight, high-volume work once its live route price is confirmed. MiniMax M3 fits long document sessions, Gemini 3.8 Flash leads on multimodal speed, and Grok 4.6 is better treated as an escalation model for harder tasks.

Michael Johnson | 2026-09-15

Fix Invalid Request After Switching Models

Fix Invalid Request After Switching Models

TL;DR Switching AI models sounds like a simple string change, but it often triggers a 400 Bad Request. An invalid request after switching models usually indicates that your new model has different rules for parameters like temperature or message roles. When you transition between providers or upgrade to reasoning-heavy models, the API schema validation becomes much stricter. If your code sends a parameter the new endpoint doesn't recognize, the system won't just ignore it; it will reject the entire payload. Success in multi-model development relies on sanitizing your requests. By understanding how different models handle system prompts, tool schemas, and context windows, you can eliminate these errors and build a more resilient AI pipeline.

Tiffany Layne | 2026-09-14