Skip to main content

Claude API Keys: Getting a Key, Pricing & Usage (2026)

You need an API key to call Claude from code. This guide covers how to get a key, current model pricing including Sonnet 5, and how to keep your key secure.

ByUpdated
🌐 This article was machine-translated and may contain inaccuracies. Read the Korean original if in doubt.

To call Claude from code, you need an API key. The API is completely separate from claude.ai subscriptions (like Pro) — it's pay-as-you-go, billed per token. This guide covers where and how to get a key, what it costs, and how to keep your key safe. (For the actual first call, see the API getting-started guide.)

🟢 Model references match the current lineup · model notice · Fable subscription
🟢 Model references match the current lineup · Claude Opus 5.5 / Claude Sonnet 5 / Claude Haiku 4.5 (higher tier: Claude Fable 5.1). This notice changes only when Anthropic ships a new model.

Fable 5 and 5.1 subscription (updated September 7, 2026): Claude Fable 5.1, released September 1, 2026, is the current Fable model and Fable 5 is now legacy. Plan terms are the same for both — Max and Team Premium plans include Fable at up to 50% of the weekly usage limit; Pro and Team Standard use usage credits (

🟢 Model references match the current lineup · Claude Opus 5.5 / Claude Sonnet 5 / Claude Haiku 4.5 (higher tier: Claude Fable 5.1). This notice changes only when Anthropic ships a new model.
0/M input, $50/M output tokens). The one-time
🟢 Model references match the current lineup · Claude Opus 5.5 / Claude Sonnet 5 / Claude Haiku 4.5 (higher tier: Claude Fable 5.1). This notice changes only when Anthropic ships a new model.
00 credit applied only to the Fable 5 transition and is not offered for 5.1. Some coding and debugging requests may be answered by an Opus model due to a security classifier (both models). See the Fable 5.1 guide and the Fable 5 availability guide for details.

Update (September 27, 2026): Claude Opus 5.5 was released on September 22, 2026 and is now the current Opus model (API claude-opus-5-5, $4 per million input tokens and $20 per million output tokens, down from Opus 5's $5/$25). Anthropic says it performs at the level of Fable 5.1 on most work and costs 40% less to run than Opus 5 on typical workloads. Opus 5 remains available but is marked legacy in the official model docs. Opus 5 prices and comparisons below reflect the pre-launch state and will be updated. Details: Claude Opus 5.5 complete guide.

Claude API pricing by model (per MTok) Model Input Output Haiku 4.5 $1 $5 Sonnet 5 (standard price, increase cancelled) $2 $10 Opus 5 $5 $25 As of Sep 2026. Sonnet 5 $2/$10 is now standard (Sep 1 $3/$15 increase cancelled). Prompt caching up to -90%, Batch API -50%. Prices may change.

Subscription vs API

This trips people up most. Claude Pro ($20/mo) does not include API usage. The API isn't a monthly subscription — it's pay-as-you-go, billed by the input tokens you send and output tokens you receive. Call nothing and you owe nothing.

How to get an API key

  1. Sign up / log in at platform.claude.com (the developer console). New accounts usually get a small amount of free credit, though the amount and terms can change.
  2. Add a payment method and top up credits. New accounts start on prepaid credits with optional auto-reload; higher-usage accounts can switch to monthly invoicing.
  3. Create a key under API Keys. The key value is often shown only once, so store it somewhere safe immediately.

Pricing by model

Pricing bills input tokens (your prompt/context) and output tokens (Claude's reply) separately, and output is ~5x input across all current models. The three recommended models as of August 2026 are in the table above.

  • Haiku 4.5 ($1/$5): cheapest; great for classification, extraction, summarization, high-volume work.
  • Sonnet 5 ($2/$10 (now the standard price — originally announced as introductory pricing through August 31, 2026; Anthropic has since cancelled the planned September 1 increase to $3/$15. Confirmed on the official pricing docs, September 2, 2026)): the current Sonnet model, released June 30, 2026. Substantially stronger than its predecessor Sonnet 4.6 on agentic tasks, coding, and tool use — at an attractive price. Call it via claude-sonnet-5 in the API.
  • Opus 5 ($5/$25): most capable; for complex coding, reasoning, and agents (the current top tier is Fable 5.1).

Cutting costs

  • Prompt caching: cache long, repeated prefixes for up to 90% off cached input.
  • Batch API: process non-urgent work in bulk for a flat 50% discount.
  • Use the right model. Sending simple tasks to Opus is a common source of overspend. Combining caching and batch helps a lot.

Rate limits

The API has per-minute request and token limits that increase by tier based on your payment and usage history. Check the limits page in the console for exact numbers. Exceeding a limit returns a 429 error.

Key security — don't skip this

  • Keep keys in environment variables, e.g. export ANTHROPIC_API_KEY="sk-ant-..."
  • Never commit keys to code or Git. A public repo can get a key stolen instantly.
  • Rotate keys periodically; if you suspect exposure, revoke and reissue in the console immediately.
  • Never put keys in front-end (browser) code — call only from your server.
How to protect your API keyNot in codeNo git commits,no frontendUse env vars.env / secretmanagersNever shareNot via chat,screenshots, emailIf leakedRevoke at once,reissue a new keyTreat keys like passwords — a leak lets others run up charges

Next steps

Once you have a key, see the API getting-started guide for the first request/response. For billing or key issues, use the platform.claude.com console and official docs.

Disclaimer: Pricing, free credits, and limit policies change often. The figures here (Haiku $1/$5, Sonnet 5 $2/$10 — now the standard price; the planned Sep 1, 2026 increase to $3/$15 was cancelled, Opus $5/$25, caching -90%, batch -50%) reflect Anthropic's official pricing at the time of writing (July 2026); check platform.claude.com for the latest. This site is not affiliated with Anthropic.

See also: Claude Model Comparison Guide

Related: Billing and subscription guide · Usage limits guide · Free plan guide

Curious what your usage would cost? Try the API cost calculator — pick a model and token counts for an instant estimate.

Was this helpful?

Keep reading