How to Get a Claude (Anthropic) API Key — and Connect It to Your Product
February 20, 2026
Updated May 2026
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://console.anthropic.com and sign up with your email, Google, or SSO.
Complete the brief onboarding: basic profile details and whether you're an individual or an organization.
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. Some cloud-hosted paths (Amazon Bedrock in certain regions) and resale or OEM-style arrangements still require Anthropic approval, but that's at the contract layer, not the baseline API.
Note: console.anthropic.com and platform.claude.com both redirect to the same developer 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:
- Click API Keys in the left sidebar (or go directly to
console.anthropic.com/settings/keys) - Click Create Key
- Name it clearly —
prod-backend,staging,dev-testing - Select the workspace — keys are scoped to a single workspace. If you have multiple workspaces (e.g., "Prod" and "Sandbox"), create and manage keys separately in each one
- Set permissions — choose full access or read-only depending on what the key needs to do. Read-only keys can call the API but cannot manage other keys or users. Keep admin-scope keys in a separate secrets store
- Copy the key immediately
The key is shown once. Anthropic does not store the secret value — close the dialog without copying and you'll need to revoke and regenerate.
Anthropic API keys start with sk-ant- followed by alphanumeric characters. Project-scoped keys may include additional sub-prefixes like 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, Java, Go) read ANTHROPIC_API_KEY automatically — 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
- Add usage alerts at 50%, 75%, and 90% thresholds
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 or Max subscription does not include API credits.
Anthropic occasionally offers promotional credits for new accounts — check your console's Billing section for any available offers. The Startup Program offers significant credit packages for qualifying early-stage companies. Neither is guaranteed for all accounts.
Step 4: Test Your API Key
Claude API calls use the x-api-key header — not Authorization: Bearer. This is one of the most common migration mistakes when coming from OpenAI.
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-sonnet-4-6",
"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:
The header is x-api-key****, not Authorization: Bearer****. Anthropic uses a custom header.
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?
Current model lineup as of May 2026, confirmed from Anthropic's official docs:
| Model | API ID | Input / MTok | Output / MTok | Context | Best for |
|---|---|---|---|---|---|
| Claude Opus 4.7 | claude-opus-4-7 | $5.00 | $25.00 | 1M tokens | Most complex reasoning, advanced agentic coding. Use when quality is the only metric. |
| Claude Sonnet 4.6 | claude-sonnet-4-6 | $3.00 | $15.00 | 1M tokens | Recommended default. Best balance of speed and intelligence for most production workloads. |
| Claude Haiku 4.5 | claude-haiku-4-5-20251001 | $1.00 | $5.00 | 200K tokens | High-volume, latency-sensitive tasks — classification, routing, extraction, summarization. |
Prices per million tokens sourced from Anthropic's official pricing page. Verify at anthropic.com/pricing before production budget planning. |
Recommended default for new integrations: claude-sonnet-4-6 — best balance of capability and cost across most use cases.
Note on Opus 4.7 tokenizer: Opus 4.7 ships with a new tokenizer that can generate up to 35% more tokens for the same input text compared to Opus 4.6. Per-token prices are unchanged, but effective cost per request can increase by up to 35%. Benchmark your workloads before migrating from Opus 4.6.
Cost-saving features:
- Batch API — 50% discount on input and output for asynchronous workloads
- Prompt caching — up to 90% savings on cached input tokens for repeated system prompts, documents, and tool definitions
Models to migrate away from immediately:
claude-sonnet-4-0,claude-opus-4-0— retired April 20, 2026; calls return errorsclaude-3-7-sonnet-*— retired October 28, 2025claude-3-5-sonnet-*— retired January 5, 2026claude-3-5-haiku-*,claude-3-haiku-*— retired February 19, 2026claude-3-sonnet-20240229— retired
Is the Claude API Free?
No. There is no permanent free tier.
The claude.ai chat app has a free plan — that is a separate product from the API. A Claude Pro subscription ($20/month) or Max subscription does not include API credits. API usage is billed additionally on a pay-per-token basis.
New accounts may receive small promotional credits — check your console's Billing section. For qualifying startups, Anthropic's Startup Program offers significant credit packages. These are conditional and not guaranteed for all accounts.
Claude API Key Format
Claude API keys start with sk-ant- followed by alphanumeric characters and dashes. Project-scoped keys may have additional sub-prefixes like sk-ant-api03-. If your key doesn't start with sk-ant-, it isn't a Claude API key.
Security Best Practices
- Never expose 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 — read-only keys for monitoring and reporting; full-access keys only where needed; admin-scope 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 per model:
- RPM — requests per minute
- ITPM — input tokens per minute
- OTPM — output tokens per minute
Limits vary by model tier and account spend history. Lighter models (Haiku) allow higher RPM/TPM at a given account tier than heavier ones (Opus). When you exceed any dimension you receive a 429 error.
Check your current limits in the Claude Console. For higher limits, contact Anthropic sales or submit a limit increase request once your account spend and use case qualify.
When you hit 429 errors, implement exponential backoff. Back off progressively (1s, 2s, 4s, 8s) until successful.
How Claude API Keys Compare to Other LLM Providers
| Provider | Auth header | Endpoint | Env var | Key format | OpenAI SDK compatible? |
|---|---|---|---|---|---|
| OpenAI | Authorization: Bearer | api.openai.com/v1 | OPENAI_API_KEY | sk- / sk-proj- | ✓ native |
| Anthropic Claude | x-api-key | api.anthropic.com/v1 | ANTHROPIC_API_KEY | sk-ant- | ✗ |
| Google Gemini | x-goog-api-key | generativelanguage.googleapis.com/v1beta | GEMINI_API_KEY | AIza... | ✗ |
| X.ai Grok | Authorization: Bearer | api.x.ai/v1 | XAI_API_KEY | xai-... | ✓ |
| Groq | Authorization: Bearer | api.groq.com/openai/v1 | GROQ_API_KEY | gsk_... | ✓ |
| Mistral AI | Authorization: Bearer | api.mistral.ai/v1 | MISTRAL_API_KEY | 32-char opaque token | ✓ |
| Cohere | Authorization: Bearer | api.cohere.ai/v1 | CO_API_KEY | not publicly documented | ✗ (own SDK) |
| DeepSeek | Authorization: Bearer | api.deepseek.com/v1 | DEEPSEEK_API_KEY | sk-... | ✓ |
| Hugging Face | Authorization: Bearer | api-inference.huggingface.co | HF_TOKEN | hf_... | partial (chat only) |
| Azure OpenAI | api-key | {resource}.openai.azure.com | AZURE_OPENAI_API_KEY | not publicly documented | ✓ (via Azure SDK) |
| AnyScale¹ | Authorization: Bearer | api.endpoints.anyscale.com/v1 | ANYSCALE_API_KEY | esecret_... | ✓ |
| ¹ Effective August 1, 2024, Anyscale Endpoints is available exclusively via the Hosted Anyscale Platform; multi-tenant LLM access was removed. |
The critical difference from OpenAI: Claude uses x-api-key not Authorization: Bearer, requires the anthropic-version header on every request, and requires max_tokens on every request. The OpenAI SDK does not work with Claude — you need Anthropic's own SDK or the raw REST API.
When to Use Claude on Amazon Bedrock, Vertex AI, or Microsoft Foundry
Claude is available directly via the Anthropic API and through three cloud platforms. The model strings are the same across platforms (e.g., claude-sonnet-4-6), but auth and request format differ.
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 uses different model IDs (
anthropic.claude-sonnet-4-6) andanthropic_version: bedrock-2023-05-31in the request body, not as a header
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's Generative AI API standardizes three core objects across providers — including Anthropic:
Model — id, max_tokens, temperature support
Prompt — model_id, messages, temperature, max_tokens, responses, tokens_used
Embedding — model_id, content, dimension, embeddings, tokens_used
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 first-party text embeddings. The recommended partner is Voyage AI (owned by MongoDB). 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 formatted for Anthropic:
GET /tools?type=anthropic - 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):
https://mcp-api.unified.to/mcphttps://mcp-api-eu.unified.to/mcp
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: invalid x-api-key
The key is wrong, expired, or revoked. Check the header name — it must be x-api-key, not Authorization. Check for trailing whitespace. Regenerate at console.anthropic.com/settings/keys if needed.
400 — invalid_request_error: model
The model string is wrong or deprecated. Check the model table above. Models retired after April 20, 2026 (claude-sonnet-4-0, claude-opus-4-0) return 400.
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.
Billing errors / credits exhausted If credits are exhausted, requests fail. Add credits in the console under Settings → Billing. Check auto-reload settings.
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 have completely separate billing. A Pro or Max subscription does not include API credits.
What does a Claude API key look like?
A string starting with sk-ant- followed by alphanumeric characters. Project-scoped keys may include additional sub-prefixes like 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.
Why does Claude use x-api-key instead of Authorization: Bearer****?
Anthropic made this design choice independently of OpenAI's convention. The x-api-key header is required on every Claude API request alongside anthropic-version. If you're migrating from OpenAI, this is the most common cause of 401 errors.
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 May 2026 — it refers to the API version, not the model release date.
Which Claude model should I use by default?claude-sonnet-4-6 for most production workloads. Use claude-opus-4-7 for the most complex reasoning tasks. Use claude-haiku-4-5-20251001 for high-volume, latency-sensitive workloads.
Can I use the OpenAI SDK with Claude?
Not directly. Claude uses x-api-key for auth, requires anthropic-version, and requires max_tokens — all differ from OpenAI's pattern. Use Anthropic's official SDK or the raw REST API.
Are keys global to my account or per workspace? Keys are per workspace. If you have multiple workspaces (e.g., "Prod" and "Sandbox"), create and manage keys separately in each one. Keys cannot see or spend usage across workspaces.
Do I need a separate API key for Claude Code? No. Claude Code uses the same Anthropic account and billing as the Claude API. You authenticate it with your existing API key or sign in with your Anthropic account directly. Usage rolls up to the same org billing.
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 January 5, 2026. Migrate to claude-sonnet-4-6. Claude 3.7 Sonnet was also retired October 28, 2025. The original Claude 4.0 models (claude-sonnet-4-0, claude-opus-4-0) were retired April 20, 2026.
Does Anthropic offer embeddings? Not first-party. The recommended partner is Voyage AI (owned by MongoDB). Anthropic's cookbook repository includes example notebooks for Voyage models paired with Claude.
How do I set the ANTHROPIC_API_KEY environment variable in Python?
export ANTHROPIC_API_KEY="sk-ant-..."
Then in Python:
import anthropic
client = anthropic.Anthropic() # picks up ANTHROPIC_API_KEY from env
message = client.messages.create(
model="claude-sonnet-4-6",
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:
- Real-time data access
- Unified pass-through architecture
- Zero storage of customer data
- Usage-based pricing aligned with API volume
- MCP-compatible integration across 450+ integrations
Claude generates intelligence. Unified connects that intelligence to structured SaaS data and authorized actions.