[BUG] Authorization header not sent when ANTHROPIC_AUTH_TOKEN is set.

Resolved 💬 4 comments Opened Mar 25, 2026 by spence10101 Closed Mar 26, 2026

Preflight Checklist

  • [x] I have searched existing issues and this hasn't been reported yet
  • [x] This is a single bug report (please file separate reports for different bugs)
  • [x] I am using the latest version of Claude Code

What's Wrong?

I'm getting

401 {"type":"error","error":{"type":"authentication_error","message":"login fail: Please carry the API secret key in the 'Authorization' field of the request header"}

from my BYOK provider even though it is set correctly:

$ cat ~/.claude/settings.json { "env": { "ANTHROPIC_BASE_URL": "https://api.minimax.io/anthropic", "ANTHROPIC_AUTH_TOKEN": "sk-cp-2j***Xs", "API_TIMEOUT_MS": "3000000", "CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC": "1", "ANTHROPIC_MODEL": "MiniMax-M2.7", "ANTHROPIC_SMALL_FAST_MODEL": "MiniMax-M2.7", "ANTHROPIC_DEFAULT_SONNET_MODEL": "MiniMax-M2.7", "ANTHROPIC_DEFAULT_OPUS_MODEL": "MiniMax-M2.7", "ANTHROPIC_DEFAULT_HAIKU_MODEL": "MiniMax-M2.7" },

What Should Happen?

Claude Code should send authorization header when ANTHROPIC_AUTH_TOKEN is set.

Error Messages/Logs

See above

Steps to Reproduce

Set ANTHROPIC_AUTH_TOKEN.
Attempt to connect to API that requires authorization header.

Claude Model

None

Is this a regression?

Yes, this worked in a previous version

Last Working Version

Unknown

Claude Code Version

2.1.83 (Claude Code)

Platform

Other

Operating System

Ubuntu/Debian Linux

Terminal/Shell

WSL (Windows Subsystem for Linux)

Additional Information

The env var seems properly set:

$ export
declare -x ANTHROPIC_AUTH_TOKEN="sk-cp-2j***Xs"
declare -x ANTHROPIC_BASE_URL="https://api.minimax.io/anthropic"

I tested the api manually with curl, and the model returned properly:

$ curl "https://api.minimax.io/anthropic/v1/messages"   -H "Authorization: Bearer sk-cp-2jsyDnOGRgns8T9KkSIUsZcy5ra135R46Y5Gi5D_3Y1F1JrAzpo7ZmsPo7epZg1gk3ccbBEjoImQjCeRwS2_v-QdeDNxA4jc9NtUp-UpirUbh7bc-wSpNXs"   -H "anthropic-version: 2023-06-01"   -H "Content-Type: application/json"   -d '{
    "model": "MiniMax-M2.7",
    "max_tokens": 50,
    "messages": [
      {
        "role": "user",
        "content": "Hello, testing the MiniMax Anthropic endpoint!"
      }
    ]
  }'
{"id":"061393d38ccee593f6558196ed976a72","type":"message","role":"assistant","model":"MiniMax-M2.7","content":[{"thinking":"The user is saying \"Hello, testing the MiniMax Anthropic endpoint!\" which seems like a greeting and a test message. I should respond in a friendly manner acknowledging their message. Since they mentioned \"MiniMax Anthropic endpoint\", they might","signature":"7c6886440f4c869098a6d729e2d98e5e247c20d233651d95317030101860aff4","type":"thinking"}],"usage":{"input_tokens":51,"output_tokens":50},"stop_reason":"max_tokens","base_resp":{"status_code":0,"status_msg":""}}

Finally, I set the endpoint url to localhost and proved Claude Code isn't sending the header:

$ nc -l 30085
POST /v1/messages?beta=true HTTP/1.1
Accept: application/json
Authorization: Bearer sk-cp-2jsyDnOGRgns8T9KkSIUsZcy5ra135R46Y5Gi5D_3Y1F1JrAzpo7ZmsPo7epZg1gk3ccbBEjoImQjCeRwS2_v-QdeDNxA4jc9NtUp-UpirUbh7bc-wSpNXssk-cp-2jsyDnOGRgns8T9KkSIUsZcy5ra135R46Y5Gi5D_3Y1F1JrAzpo7ZmsPo7epZg1gk3ccbBEjoImQjCeRwS2_v-QdeDNxA4jc9NtUp-UpirUbh7bc-wSpNXs
Content-Type: application/json
User-Agent: claude-cli/2.1.83 (external, cli)
X-Stainless-Arch: x64
X-Stainless-Lang: js
X-Stainless-OS: Linux
X-Stainless-Package-Version: 0.74.0
X-Stainless-Retry-Count: 0
X-Stainless-Runtime: node
X-Stainless-Runtime-Version: v24.3.0
X-Stainless-Timeout: 3000
anthropic-beta: claude-code-20250219,interleaved-thinking-2025-05-14,prompt-caching-scope-2026-01-05,effort-2025-11-24
anthropic-dangerous-direct-browser-access: true
anthropic-version: 2023-06-01
x-app: cli
Connection: keep-alive
Host: localhost:30085
Accept-Encoding: gzip, deflate, br, zstd
Content-Length: 1498

{"model":"MiniMax-M2.7","messages":[{"role":"user","content":[{"type":"text","text":"hello"}]}],"system":[{"type":"text","text":"x-anthropic-billing-header: cc_version=2.1.83.be2; cc_entrypoint=cli; cch=e87ef;"},{"type":"text","text":"You are Claude Code, Anthropic's official CLI for Claude."},{"type":"text","text":"Generate a concise, sentence-case title (3-7 words) that captures the main topic or goal of this coding session. The title should be clear enough that the user recognizes the session in a list. Use sentence case: capitalize only the first word and proper nouns.\n\nReturn JSON with a single \"title\" field.\n\nGood examples:\n{\"title\": \"Fix login button on mobile\"}\n{\"title\": \"Add OAuth authentication\"}\n{\"title\": \"Debug failing CI tests\"}\n{\"title\": \"Refactor API client error handling\"}\n\nBad (too vague): {\"title\": \"Code changes\"}\nBad (too long): {\"title\": \"Investigate and fix the issue where the login button does not respond on mobile devices\"}\nBad (wrong case): {\"title\": \"Fix Login Button On Mobile\"}"}],"tools":[],"metadata":{"user_id":"{\"device_id\":\"2fa1a1076376bf7b0ef554280976f40cbd2ca1b70afe0a42c4d6c659f8f45ddc\",\"account_uuid\":\"\",\"session_id\":\"b0ffd66a-1450-4acf-83cd-fcfa7d35fcfa\"}"},"max_tokens":32000,"temperature":1,"output_config":{"effort":"medium","format":{"type":"json_schema","schema":{"type":"object","properties":{"title":{"type":"string"}},"required

/status shows

  Auth token: ANTHROPIC_AUTH_TOKEN
  Anthropic base URL: https://api.minimax.io/anthropic

but debug output shows

2026-03-25T22:35:29.292Z [DEBUG] [API:request] Creating client, ANTHROPIC_CUSTOM_HEADERS present: false, has Authorization header: false

View original on GitHub ↗

This issue has 4 comments on GitHub. Read the full discussion on GitHub ↗