# Claude Code Authentication

> How Claude Code signs you in. It picks one credential in a fixed order.

**Field:** Artificial Intelligence  
**Category:** Claude Code  
**Also known as:** Claude Code login, Claude Code sign-in, Claude Code authentication precedence

## Think of it like

It is like a key ring with many keys. The door uses the first key that fits.

## Definition

Claude Code authentication is how it proves who you are before it can call a model. On first launch it opens a browser so you can sign in with a Claude plan or a Console account. It can also use an API key, a long-lived token for scripts, or a cloud provider's own login. When several are set, it picks one in a fixed order, and cloud provider settings come first. A Claude plan sign-in comes last.

## Example

Leo has a Max plan but also set ANTHROPIC_API_KEY for a script. Claude Code asks whether to use the key, and if he says yes, the key's account pays.

## Example code

```bash
claude auth login
claude auth status
```

Sign in from the shell, then check which account is in use.

## Why it matters

The key you sign in with decides who pays. A stray key can move your bill to another account.

## Common mistake

Leaving an old API key set in your shell. It wins over your plan sign-in once you approve it.

## Three principles

- **Browser first time.** Sign in once on first launch.
- **Fixed order.** Cloud settings, then keys, then plan.
- **Tokens for scripts.** No browser needed in CI.

## Related terms

- [claude auth login Command](https://learn.benibix.com/term/ai/claude-auth-login-command)
- [/login Command](https://learn.benibix.com/term/ai/login-command)
- [ANTHROPIC_API_KEY](https://learn.benibix.com/term/ai/anthropic-api-key-variable)
- [claude setup-token Command](https://learn.benibix.com/term/ai/claude-setup-token-command)
- [Claude Code Cloud Providers](https://learn.benibix.com/term/ai/claude-code-cloud-providers)
- [Authentication](https://learn.benibix.com/term/development/authentication)

## Taught in

- [Claude Code and Its Surfaces](https://learn.benibix.com/learn/ai-claude-code/claude-code-and-its-surfaces): Claude Code, 1/16

![On the left, three ways to sign in: a Claude plan through the browser, a Console API key, and a cloud provider such as Amazon Bedrock, Google Cloud or Microsoft Foundry. The plan path has a meter for a session window and a weekly window. On the right, Claude Code sends usage numbers out through OpenTelemetry to a dashboard.](https://learn.benibix.com/diagrams/ai8-cc-accounts.svg)

---

Source: https://learn.benibix.com/term/ai/claude-code-authentication
Author: Behnia Zarei (a developer in Vienna, Austria, who builds and teaches data, AI and business intelligence at BENIBIX)
Publisher: BENIBIX Learn (https://learn.benibix.com/)
Last updated: 2026-11-19
Licence: CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Quote freely with attribution.
