#10961: feat: Support routingHint and improve URL routing for Anthropic (Claude Max) subscriptions
commands
agents
stale
Cluster:
Auth Improvements and Fixes
## Summary
This PR adds support for the `routingHint` parameter in Anthropic (Claude Max/Pro) subscription-based "token" authentication. It also improves the onboarding flow to optionally prompt for this value and ensures that the authentication headers correctly include the routing hint when provided.
## Changes
- **Credential Schemas**: Added `routingHint` to `TokenCredential` and `OAuthCredential` types.
- **Zod Schema**: Updated `OpenClawSchema` to include `routingHint` in auth profiles.
- **Onboarding**: Updated the Anthropic onboarding flow to ask for an optional routing hint when using setup-tokens or session tokens.
- **Auth Logic**: Updated `buildOAuthApiKey` and `resolveApiKeyForProfile` to include the `routingHint` in the returned API key payload for the Anthropic provider.
## Why this is needed
Claude Max/Pro subscription sessions often require a `routingHint` to correctly route requests through Anthropic's infrastructure. Without this, users frequently encounter 401 (Unauthorized) errors even with valid session tokens. Additionally, the default URL patterns for standard API keys often cause 404 errors when used with subscription tokens; this PR provides the infrastructure to pass necessary hints to the underlying model provider.
## Verification
Tested locally by manually injecting the `routingHint` into `auth-profiles.json` and verifying successful communication with Claude Opus 4.6 using a Max subscription.
<!-- greptile_comment -->
<h2>Greptile Overview</h2>
<h3>Greptile Summary</h3>
- Adds an optional `routingHint` field to auth profile config/schema and to token/OAuth credential types.
- Updates Anthropic onboarding to prompt for and persist a `routingHint` alongside setup/session tokens.
- Extends API key resolution to wrap Anthropic token/OAuth auth material as JSON `{ token, routingHint }` when a routing hint is present.
- Updates OAuth API key construction to optionally emit routing-hint payloads for Anthropic in addition to existing Google projectId payloads.
<h3>Confidence Score: 3/5</h3>
- This PR is close to merge-ready but has a functional issue where Anthropic routingHint can be dropped after OAuth refresh, and the onboarding flow can persist invalid routingHint values.
- Core schema/type changes are straightforward, but the OAuth refresh path returns an apiKey that is not re-wrapped with routingHint (so behavior changes over time), and the new routingHint prompt has no validation, increasing likelihood of persistent misconfiguration.
- src/agents/auth-profiles/oauth.ts; src/commands/auth-choice.apply.anthropic.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
#10492: fix(auth): store Anthropic setup-token as type:oauth for auto-refresh
by sparck75 · 2026-02-06
77.7%
#3196: docs: clarify auth-profiles.json format for Claude Max setup-tokens
by aadeina · 2026-01-28
77.7%
#13484: feat(auth): restore Claude Code CLI OAuth credential sync
by joshpocock · 2026-02-10
77.1%
#9163: Fix: Save Anthropic setup token to config file
by vishaltandale00 · 2026-02-04
74.6%
#10108: fix: override stale Anthropic OAuth stealth headers for Opus 4.6
by CivilBooks · 2026-02-06
74.3%
#22105: feat(auth): add refreshable Anthropic OAuth login flow
by sauerdaniel · 2026-02-20
74.0%
#2123: fix(auth): sync from Claude CLI keychain before OAuth refresh
by jorge123255 · 2026-01-26
73.6%
#11938: feat: support ANTHROPIC_AUTH_TOKEN environment variable
by EricMymj · 2026-02-08
73.4%
#6400: fix: set correct mode for Anthropic OAuth auth (#2697)
by coupclawbot · 2026-02-01
73.3%
#23700: feat: Claude CLI personal-use auth (no API key required) + native A...
by 88plug · 2026-02-22
72.7%