[Bug]: Claude instance with custom ANTHROPIC_BASE_URL sends the app OAuth token instead of ANTHROPIC_AUTH_TOKEN (401)#20245

openedOct 16, 2026byDDamonYoungWork

Summary

Since updating to the beta today, a Claude provider instance configured with a custom ANTHROPIC_BASE_URL and ANTHROPIC_AUTH_TOKEN no longer sends that token. Every request reaches the custom endpoint with the app's own Claude OAuth token (sk-ant-…) in Authorization, so the endpoint returns 401 and the thread sits on "connecting to provider".

This is the setup described in #4835 (a second Claude instance pointed at a gateway, with the token stored as a server secret). It worked on the previous release until the update.

Environment

  • T3 Code (Beta) 0.1.0, macOS 27.0.1, Apple Silicon
  • Claude Code CLI 2.1.301, agent-sdk 0.3.299
  • Instance: driver claudeAgent, env ANTHROPIC_BASE_URL=http://127.0.0.1:<port> (a local Anthropic-compatible proxy), ANTHROPIC_AUTH_TOKEN saved as a sensitive value

Steps to reproduce

  1. Add a second claudeAgent instance with ANTHROPIC_BASE_URL pointing at any Anthropic-compatible endpoint that checks its own API key, and set ANTHROPIC_AUTH_TOKEN to that key.
  2. Stay signed in to Claude in T3 on the default instance.
  3. Start a thread on the custom instance and send a message.

Expected: the request carries Authorization: Bearer <ANTHROPIC_AUTH_TOKEN>. Actual: the request carries the app's Claude OAuth token. The endpoint logs 401 "Invalid API key".

What I checked

  • The spawned CLI process has the correct ANTHROPIC_AUTH_TOKEN in its environment (right length, re-entered after the update), so the secret store is fine.
  • The process also gets CLAUDE_CODE_SDK_HAS_HOST_AUTH_REFRESH, CLAUDE_CODE_OAUTH_SCOPES=user:inference and CLAUDE_CODE_ACCOUNT_UUID, which it did not get before.
  • Pointing the instance at a wrapper binary that unsets those variables, and also exporting ANTHROPIC_API_KEY, still sends the OAuth token. So the token appears to arrive over the SDK control channel, not the environment.
  • Running the same CLI by hand with the same env sends ANTHROPIC_AUTH_TOKEN as expected. The override only happens when T3 launches it.

Suggested fix

Skip host-managed Claude auth for an instance whose environment sets ANTHROPIC_BASE_URL, ANTHROPIC_AUTH_TOKEN or ANTHROPIC_API_KEY, or add a per-instance switch to turn host auth off.

Workaround

A local relay between the CLI and the endpoint that replaces the inbound Authorization header with the endpoint's key.

Fresh triage: this reports a credential-selection failure, with no concrete attacker or unprivileged-access path described. No duplicate found among open issue titles in the last 90 days using ANTHROPIC, OAuth, gateway/custom endpoint, and 401/Invalid API key terms. Runtime reproduction has not been performed. Investigating the proposed fix requires changing host-managed Claude authentication or credential precedence, which is outside the automated triage fix scope. Leaving this open for maintainer investigation.

Synced from GitHub

Retested on T3 Code (Beta) 0.1.1 (macOS, Apple Silicon), Claude Code CLI 2.1.308, with the app's bundled Agent SDK 0.3.276. I can't confirm where the 0.3.299 in the original report came from, so please treat 0.3.276 as the relevant version.

The default Claude instance is signed in through the Claude CLI's own OAuth subscription login (Settings shows "Authenticated · Claude Pro Subscription"), not a separate T3 sign-in. That was also the setup on the day of the report.

With the default instance enabled and signed in, I started a new thread on the second instance (ANTHROPIC_BASE_URL set to a local gateway, ANTHROPIC_AUTH_TOKEN stored as a sensitive value). Every /v1/messages request carried the configured token, and the gateway logged no 401. The spawned CLI process also no longer gets CLAUDE_CODE_SDK_HAS_HOST_AUTH_REFRESH, CLAUDE_CODE_OAUTH_SCOPES or CLAUDE_CODE_ACCOUNT_UUID, which it did get on the build where this failed.

This no longer reproduces for me on 0.1.1. Fine to close unless you want me to test anything else.

Note

🤖 GPT-6.1 Terra [1m] responding on behalf of Theo

Closing as resolved after the reporter retested the original two-instance setup on 0.1.1 and confirmed that requests use the configured gateway token without 401 errors. #20245 comment