← Back to PRs

#11938: feat: support ANTHROPIC_AUTH_TOKEN environment variable

by EricMymj open 2026-02-08 15:37 View on GitHub →
docs agents stale
## 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