How to Get a Claude (Anthropic) API Key — and Connect It to Your Product
·
Claude is Anthropic's family of large language models. If you're building an AI-powered SaaS product, internal assistant, or agent system, you'll need an Anthropic API key.
This guide covers:
- Creating your Anthropic account
- Generating and securing your API key
- Setting up billing
- Testing your first request
- Using Claude through Unified's Generative AI API
- Connecting Claude to SaaS platforms via Unified MCP
Step 1: Create an Anthropic Account
Go to https://platform.claude.com (the Claude Console; console.anthropic.com redirects there) and create an account.
API access is self-serve for most accounts. You won't hit an approval queue just to get an API key — sign up, add a payment method, and you're in.
Note: console.anthropic.com now redirects to platform.claude.com, the Claude Console. If you already use claude.ai for chat, you still need a separate API console account — they share the same login but are different products with separate billing.
Step 2: Generate an API Key
Once logged in:
- Open the API keys page (
platform.claude.com/settings/keys) - Click Create Key
- Name it clearly —
prod-backend,staging,dev-testing - Optionally choose a workspace to scope the key to. A key that works across several workspaces must send the
anthropic-workspace-idheader on each request - Choose the key type and expiry. A personal key acts as you; a service account key is for CI, production services and agents. Admin API keys are a separate type for organization management; keep them in a separate secrets store
- Copy the key immediately
The key is shown once. If you close the dialog without copying it, you can't view it again; create a new key and delete the old one.
Claude API keys start with sk-ant- (Anthropic's own example uses sk-ant-api03-). If your key doesn't start with sk-ant-, it may have been copied incorrectly.
Store as an environment variable:
# macOS / Linux
export ANTHROPIC_API_KEY="sk-ant-..."
# Windows PowerShell
$env:ANTHROPIC_API_KEY = "sk-ant-..."
The official Anthropic SDKs (Python, TypeScript, C#, Go, Java, PHP and Ruby, as of 20 October 2026) read ANTHROPIC_API_KEY automatically, so you don't pass the key in code.
Never:
- Embed keys in frontend code
- Commit keys to Git, even private repos
- Share keys in logs, screenshots, or Slack
Step 3: Set Up Billing
Anthropic's API uses a prepaid credit model. Without credits your key will not process requests.
In the console go to Settings → Billing:
- Add a payment method
- Purchase initial credits
- Configure auto-reload if you want uninterrupted service
- Set a monthly spend cap to prevent runaway costs
There is no permanent free tier for the Claude API. The chat app at claude.ai has a free plan, but API access is billed separately from any subscription. A Claude Pro subscription does not include API credits. As of 20 October 2026, Max and Team plans include monthly API credits (Max 5x: $100; Max 20x: $200) that you claim by linking a Console organization; unused credits don't roll over.
Check the Promotional credits section of your Billing page for any credits on your account. Anthropic's Claude for Startups program offers API credits through partner VCs, but as of 20 October 2026 it isn't accepting new applications.
Step 4: Test Your API Key
As of 20 October 2026, Anthropic's docs list Authorization: Bearer as the preferred auth header; the older x-api-key header still works. The example below uses x-api-key, which matches most existing code, and claude-haiku-5-5, which Anthropic's models overview lists as current on 20 October 2026.
curl https://api.anthropic.com/v1/messages \
-H "x-api-key: $ANTHROPIC_API_KEY" \
-H "anthropic-version: 2023-06-01" \
-H "content-type: application/json" \
-d '{
"model": "claude-haiku-5-5",
"max_tokens": 1024,
"messages": [
{"role": "user", "content": "Explain what an API key is in two sentences."}
]
}'
Three things that trip people up coming from OpenAI:
Two auth headers work. Authorization: Bearer is preferred and x-api-key is the legacy option (as of 20 October 2026).
The anthropic-version: 2023-06-01 header is required on every request. The date refers to the API version, not the model. It has not changed despite multiple model generations. Omitting it causes errors.
max_tokens is required on every request. Unlike OpenAI, you cannot omit it and let the API decide. Always include it in your request body.
A successful response returns Claude's output in a content array.
Which Claude Model Should You Use?
Anthropic's recommended starting point (as of 20 October 2026): claude-opus-5-5. Use claude-sonnet-5-5 when cost or latency matters more. For the full current lineup, see Anthropic's models overview.
Model prices change often, so check Anthropic's pricing page before production budget planning.
Note on tokenizers: Claude 4.7 and later models use a newer tokenizer that produces approximately 30% more tokens for the same text than Claude 4.6 and earlier (per Anthropic's pricing page, 20 October 2026). Benchmark your workloads before migrating from a 4.6 or earlier model.
Cost-saving features:
- Batch API — 50% discount on input and output for asynchronous workloads
- Prompt caching: cache reads cost 10% or less of the base input price, depending on the model (as of 20 October 2026); cache writes cost more than standard input
Models to migrate away from immediately:
claude-sonnet-4-20250514,claude-opus-4-20250514(Claude Sonnet 4, Opus 4): retired June 15, 2026claude-3-7-sonnet-*: retired February 19, 2026claude-3-5-sonnet-*: retired October 28, 2025claude-3-5-haiku-*: retired February 19, 2026;claude-3-haiku-*: retired April 20, 2026claude-3-sonnet-20240229: retired July 21, 2025claude-sonnet-4-5-20250929: deprecated; retires November 30, 2026 (as of 20 October 2026)
Is the Claude API Free?
No. There is no permanent free tier.
The claude.ai chat app has a free plan, which is a separate product from the API. A Claude Pro subscription (plan prices) does not include API credits; as of 20 October 2026, Max and Team plans include a monthly API credit allowance. Usage beyond that is billed per token.
Check the Promotional credits section of your Billing page for any credits on your account. Anthropic's Claude for Startups program offers API credits through partner VCs, but as of 20 October 2026 it isn't accepting new applications.
Claude API Key Format
Claude API keys start with sk-ant- (Anthropic's own example uses sk-ant-api03-). If your key doesn't start with sk-ant-, it isn't a Claude API key.
Security Best Practices
- Never put keys in frontend code. All Claude API calls must go through a trusted backend
- Use separate keys per environment — dev, staging, and prod should never share a key
- Use least privilege. Use service account keys for workloads, scope keys to a single workspace where you can, and keep Admin API keys in a separate secrets store
- Rotate quarterly — not just when you suspect a leak
- Set a hard monthly spend cap — a runaway loop without a cap is expensive
- Monitor usage daily — watch for unexpected spikes at unusual hours
- Use a secrets manager in production — AWS Secrets Manager, GCP Secret Manager, HashiCorp Vault
- Delete unused keys — unused keys are an unnecessary attack surface
Rate Limits
Anthropic enforces three rate-limit dimensions per organization, for each model class:
- RPM — requests per minute
- ITPM — input tokens per minute
- OTPM — output tokens per minute
Limits vary by model and by usage tier (Evaluation, Start, Build, Scale, Custom as of 20 October 2026). Your organization moves up tiers automatically based on usage history and account standing. When you exceed any dimension you receive a 429 error.
Check your current limits on the Console's Rate limits page (platform.claude.com/usage/limits). Use Request tier increase there, or contact sales for limits above the Scale tier.
When you hit a 429, wait for the number of seconds in the retry-after header before retrying. A 429 without retry-after usually means your tier's monthly spend cap was reached, and retrying won't help.
How Claude API Keys Compare to Other LLM Providers
Here's how Claude compares with OpenAI and Gemini, as of 20 October 2026:
| Provider | Auth header | Endpoint | Env var | Key format | OpenAI SDK compatible? |
|---|---|---|---|---|---|
| OpenAI | Authorization: Bearer | api.openai.com/v1 | OPENAI_API_KEY | not documented by OpenAI | ✓ native |
| Anthropic Claude | Authorization: Bearer (or legacy x-api-key) | api.anthropic.com/v1 | ANTHROPIC_API_KEY | sk-ant- | partial (testing layer) |
| Google Gemini | x-goog-api-key | generativelanguage.googleapis.com/v1beta | GEMINI_API_KEY | check Google's docs | ✓ (compatibility endpoint) |
The main differences from OpenAI: Claude requires the anthropic-version header and max_tokens on every request. Anthropic offers an OpenAI SDK compatibility layer for testing, but as of 20 October 2026 it recommends its own SDKs or the REST API for production. |
When to Use Claude on Amazon Bedrock, Vertex AI, or Microsoft Foundry
Claude is available directly through the Claude API and, as of 20 October 2026, through Amazon Bedrock, Claude Platform on AWS, Google Cloud's Agent Platform (formerly Vertex AI) and Microsoft Foundry. Model IDs match the Claude API on Claude Platform on AWS and Foundry; Bedrock adds an anthropic. prefix.
Use the direct Anthropic API when:
- You want the simplest setup and fastest access to new models
- You're multi-cloud and don't need to route through a specific cloud's AI platform
- You prefer Anthropic's own usage dashboards and cost APIs
Use Amazon Bedrock when:
- Your infrastructure runs on AWS and you want to standardize on IAM, CloudWatch, VPC endpoints, and AWS Organizations for governance
- You want Claude as just another AWS service with consistent security policies, logging, and cost controls
- Note: Bedrock model IDs add an
anthropic.prefix (e.g.anthropic.claude-opus-5-5). As of 20 October 2026, models from Opus 4.7 onward use Bedrock's Messages endpoint with the same request body as the Claude API.
Use Claude Platform on AWS when:
- You want AWS Marketplace billing with Anthropic-operated infrastructure
- You need the same model IDs and lifecycle as the direct API (not Bedrock-style IDs)
Use Vertex AI when:
- Your infrastructure is on Google Cloud and you need GCP IAM, audit logs, VPC Service Controls, or provisioned throughput
- Note: Vertex passes the model in the endpoint URL, not the request body, and uses
anthropic_version: vertex-2023-10-16in the body
Use Microsoft Foundry when:
- Your organization is on Azure and requires Azure-native billing and compliance controls
Using Claude in a Multi-Model Architecture
Most AI-native SaaS teams don't rely on a single provider long term. Common reasons: cost optimization, fallback when one provider degrades, model specialization, enterprise customer preference.
Instead of building separate integrations for Claude, OpenAI, Gemini, Groq, and Cohere, you can integrate once against Unified's Generative AI API.
Build once across LLM providers
Unified.to's Generative AI API has eight objects (as of 19 October 2026). On Anthropic Claude it supports Model, Prompt, Skill and Memory:
Model — id, max_tokens, temperature support
Prompt — model_id, messages, temperature, max_tokens, responses, tokens_used
Skill: the Anthropic skills a prompt can use (skill_ids)
Memory: memory stores and memories for an end user
On Claude, prompts also take mcp_url and mcp_authorization_token.
This enables:
- Switching between Claude and other providers without rewriting integration code
- Running the same prompt across models and comparing outputs
- Routing requests based on cost or availability
- Keeping product logic provider-agnostic
Note: Anthropic does not offer its own embedding model; its docs point to Voyage AI by MongoDB as one option. Unified's embedding objects work with supported embedding providers.
Let Claude take action via Unified MCP
Text generation is only part of a production AI feature. Real AI products require structured reads and writes against customer SaaS platforms — retrieving candidates from an ATS, updating CRM deals, fetching documents, creating tickets, writing back notes.
Unified's MCP server connects Claude to customer integrations using Anthropic's tool-use flow.
Claude returns tool_use blocks when it decides to call a tool:
- Fetch tools with
GET /tools?type=openaiand rename each tool'sparameterstoinput_schema, the key Anthropic's Messages API expects (there is noanthropictype, as of 26 October 2026). Alternatively, skip this loop and point Anthropic's MCP connector at your Unified MCP URL. - Include tools in your Claude API request
- Claude responds with a
tool_useblock:
{
"type": "tool_use",
"id": "toolu_123",
"name": "list_candidates",
"input": { "limit": 100 }
}
- Call Unified:
POST /tools/{id}/call - Return the tool result back to Claude
MCP URLs (regional):
- US:
https://mcp-api.unified.to/mcp - EU:
https://mcp-api-eu.unified.to/mcp - AU:
https://api-au.unified.to/mcp
A credential works only on its own region's host. Send the token in the Authorization: Bearer header, never in the URL; keep your workspace API key on your server and give agents a connection-scoped signed token, which works for one connection only.
MCP safety controls:
hide_sensitive=true— removes PII fields from tool resultspermissions=...— restricts what the connection can dotools=...— limits the tool set to reduce model overloaddefer_tools— lowers tool token usage
LLMs have tool limits. Scoping is not optional — it's required for stable deployments.
Troubleshooting Common Errors
401 — authentication_error
The key is wrong, expired, or revoked. Send it as Authorization: Bearer <key> or x-api-key: <key>, and check for trailing whitespace. Create a new key at platform.claude.com/settings/keys if needed.
400 — invalid_request_error: model
The model string is wrong or deprecated. Check the model section above. Retired models (for example claude-sonnet-4-20250514, retired June 15, 2026) return an error.
400 — max_tokens missing or unexplained 400 errors
Anthropic requires max_tokens on every Messages request. Unlike OpenAI, you cannot omit it. Always include "max_tokens": 1024 (or your desired limit) in every request body. If you're porting code from OpenAI, this is the most common silent failure.
400 — anthropic-version missing
The anthropic-version: 2023-06-01 header is required on every request. Omitting it returns an error.
429 — rate_limit_error
You've hit RPM, ITPM, or OTPM limits. Implement exponential backoff. Check your current limits in the console.
529 — overloaded_error
Anthropic's servers are temporarily at capacity. Retry with backoff. This is not a rate limit error — it resolves on its own.
402 — billing_error
There's a problem with your billing or credits. Add credits in the Console under Settings → Billing and check auto-reload. (Reaching a spend limit you set returns a 400; reaching your tier's monthly cap returns a 429.)
FAQ
What's the difference between claude.ai and the Anthropic API?claude.ai is the consumer chat interface — it has a free tier and paid subscription plans. The Anthropic API is for developers building applications programmatically. They share the same underlying models but bill separately. Pro doesn't include API credits; as of 20 October 2026, Max and Team plans include a monthly API credit allowance.
What does a Claude API key look like?
A string starting with sk-ant-. Anthropic's own example uses sk-ant-api03-.
Is the Claude API free? No. There is no permanent free tier. API access is pay-per-token. Check your console for any promotional credits available to your account.
Does Claude use x-api-key or Authorization: Bearer****?
Both work. As of 20 October 2026, Anthropic's docs list Authorization: Bearer as preferred and x-api-key as the legacy header, which is still supported. Every request also needs anthropic-version.
What is the anthropic-version header?
A required header on every Claude API request. The current value is 2023-06-01. Despite the date, this is still the correct value as of 20 October 2026. It refers to the API version, not a model release date.
Which Claude model should I use by default? As of 20 October 2026, Anthropic recommends starting with claude-opus-5-5. Use claude-fable-5-1 for the most demanding reasoning, claude-sonnet-5-5 for speed and cost, and claude-haiku-5-5 for high-volume, latency-sensitive tasks.
Can I use the OpenAI SDK with Claude?
For testing, yes: point the OpenAI SDK at https://api.anthropic.com/v1/ with your Claude API key. Anthropic says the layer is not meant for production (prompt caching isn't supported, and several parameters are ignored), so use Anthropic's SDKs or the REST API in production.
Are keys global to my account or per workspace?
Either. You can scope a key to one workspace, or use a personal or service account key across several workspaces by sending the anthropic-workspace-id header on each request.
Do I need a separate API key for Claude Code?
No. Claude Code can use your Pro or Max subscription, or an API key billed at standard API rates. If ANTHROPIC_API_KEY is set, Claude Code uses it instead of your subscription.
Can I use a Claude API key with Amazon Bedrock or Vertex AI? No. Bedrock and Vertex use AWS and Google Cloud authentication respectively — not Anthropic API keys. The Claude models are the same, but the auth flow is different. Useful if you already have AWS or GCP procurement set up.
What happened to Claude 3.5 Sonnet?
Retired October 28, 2025. Anthropic recommends migrating to claude-sonnet-5-5. Claude 3.7 Sonnet retired February 19, 2026, and Claude Sonnet 4 and Opus 4 retired June 15, 2026.
Does Anthropic offer embeddings? Not first-party. Anthropic's embeddings guide uses Voyage AI by MongoDB as its example provider.
How do I set the ANTHROPIC_API_KEY environment variable in Python?
export ANTHROPIC_API_KEY="sk-ant-..."
Then in Python (this example uses claude-haiku-5-5, current as of 20 October 2026):
import anthropic
client = anthropic.Anthropic() # picks up ANTHROPIC_API_KEY from env
message = client.messages.create(
model="claude-haiku-5-5",
max_tokens=1024,
messages=[
{"role": "user", "content": "Explain what an API key is in two sentences."}
]
)
print(message.content)
Key takeaway
Calling Claude directly is straightforward. Building multi-model routing, embedding pipelines, agent-based write actions, and enterprise-grade SaaS integrations requires infrastructure.
Unified was built for AI-native SaaS teams that need:
- Pass-through reads at request time, and writes on supported integrations
- No customer records at rest; connection credentials and operational metadata encrypted at rest
- Usage-based pricing aligned with API volume
- MCP-compatible integration across 2154 integrations
Claude generates intelligence. Unified connects that intelligence to structured SaaS data and authorized actions.