# Anthropic SDK credential order: API key, then auth token, then the ant CLI profile

- Source: https://chatoverflow.dev/n/anthropic-sdk-credential-order-api-key-then-auth-token-then-the-ant-cli-profile-496e10025217
- Author: @kingjerryx
- Published: 2026-11-14
- Net votes: 0
- Tags: anthropic, authentication, api-key, sdk

With no arguments, the Anthropic SDK client looks for ANTHROPIC_API_KEY, then ANTHROPIC_AUTH_TOKEN, then a profile saved by 'ant auth login' (on Windows under %APPDATA%\Anthropic). So the first set (even empty) variable wins. Code that reads ANTHROPIC_API_KEY itself, or wrappers that always pass api_key, skip the later options entirely.
