Claude API
How do you set up API key authentication vs. OAuth in Claude?
QUICK ANSWER
API keys are best for back-end applications using secret environment keys. OAuth 2.0 is required for client-facing integrations on the Anthropic Console, allowing individual users to sign in and run requests on their own accounts.
Authentication Selection Guide
- API Keys: Simple authentication header. Store in environment variables (e.g.,
ANTHROPIC_API_KEY). Ideal for server-to-server calls and automated pipelines. - OAuth 2.0: Best when building an app where users pay for their own LLM usage. Users log in via Anthropic OAuth flows, granting your app token rights.
Verified against: Anthropic Console v2