#11938: feat: support ANTHROPIC_AUTH_TOKEN environment variable
docs
agents
stale
Cluster:
Model Configuration Enhancements
## Summary
Add support for the `ANTHROPIC_AUTH_TOKEN` environment variable as a fallback option for Anthropic authentication, alongside `ANTHROPIC_OAUTH_TOKEN` and `ANTHROPIC_API_KEY`.
This allows users who have `ANTHROPIC_AUTH_TOKEN` configured in their environment to use OpenClaw without renaming the variable.
## Changes
- **src/agents/model-auth.ts**: Added `ANTHROPIC_AUTH_TOKEN` as fallback in environment variable resolution
- **docs/providers/anthropic.md**: Updated documentation with environment variable priority table
## Testing
Tested with local OpenClaw instance using custom API endpoint:
```bash
export ANTHROPIC_AUTH_TOKEN="cr_..."
export ANTHROPIC_BASE_URL="https://custom.api.endpoint"
openclaw agent --agent main --message "test"
```
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
<!-- greptile_comment -->
<h2>Greptile Overview</h2>
<h3>Greptile Summary</h3>
This PR adds `ANTHROPIC_AUTH_TOKEN` as an additional environment-variable fallback when resolving Anthropic credentials, and documents the env var priority order in the Anthropic provider docs.
The new env var integrates into the shared auth resolution path (`resolveEnvApiKey` -> `resolveApiKeyForProvider`), which is also used to drive user-facing status output and certain provider-specific defaults (e.g., Anthropic cache retention defaults for API-key auth).
<h3>Confidence Score: 3/5</h3>
- This PR is likely safe to merge, but may misclassify `ANTHROPIC_AUTH_TOKEN` auth mode in a way that changes runtime behavior.
- The change is small and localized, but auth mode is inferred from env var names; adding a new token-like env var without updating mode inference can cause incorrect mode selection, impacting defaults (prompt caching) and status/cost reporting.
- src/agents/model-auth.ts
<!-- greptile_other_comments_section -->
<sub>(2/5) Greptile learns from your feedback when you react with thumbs up/down!</sub>
<!-- /greptile_comment -->
Most Similar PRs
#7821: feat: Support ANTHROPIC_BASE_URL environment variable for custom en...
by y1y2u3u4 · 2026-02-03
81.4%
#13650: feat(agents): support env var overrides for default provider and model
by xrehpicx · 2026-02-10
79.9%
#12059: feat(agents): Add Azure AI Foundry credential support
by lisanyambere · 2026-02-08
77.8%
#10108: fix: override stale Anthropic OAuth stealth headers for Opus 4.6
by CivilBooks · 2026-02-06
76.4%
#10492: fix(auth): store Anthropic setup-token as type:oauth for auto-refresh
by sparck75 · 2026-02-06
76.1%
#9163: Fix: Save Anthropic setup token to config file
by vishaltandale00 · 2026-02-04
74.7%
#10346: Add Anthropic to implicit model catalog (Opus 4.6 allowlist)
by nicks2bo · 2026-02-06
74.7%
#6400: fix: set correct mode for Anthropic OAuth auth (#2697)
by coupclawbot · 2026-02-01
73.9%
#22105: feat(auth): add refreshable Anthropic OAuth login flow
by sauerdaniel · 2026-02-20
73.5%
#10961: feat: Support routingHint and improve URL routing for Anthropic (Cl...
by catveloper · 2026-02-07
73.4%