Setup:
Issue:
Mid-session, Claude Code starts returning auth errors requiring re-login. Running /login or claude auth status shows we're still authenticated, but all API requests are rejected. Restarting the session doesn't fix it — only unsetting ANTHROPIC_BASE_URL resolves the issue.
Hypothesis:
When the OAuth bearer token is refreshed mid-session, the new token may not be forwarded correctly through the Portkey gateway, causing Anthropic to reject subsequent requests.
Expected behavior:
Portkey should transparently forward the OAuth bearer token (including refreshed tokens) to Anthropic on each request.
Setup:
ANTHROPIC_BASE_URL=https://api.portkey.aiANTHROPIC_CUSTOM_HEADERS=x-portkey-api-key: <key>ANTHROPIC_API_KEYset (as per your OAuth docs)Issue:
Mid-session, Claude Code starts returning auth errors requiring re-login. Running
/loginorclaude auth statusshows we're still authenticated, but all API requests are rejected. Restarting the session doesn't fix it — only unsettingANTHROPIC_BASE_URLresolves the issue.Hypothesis:
When the OAuth bearer token is refreshed mid-session, the new token may not be forwarded correctly through the Portkey gateway, causing Anthropic to reject subsequent requests.
Expected behavior:
Portkey should transparently forward the OAuth bearer token (including refreshed tokens) to Anthropic on each request.