[Bug] Custom Provider Authentication Broken in v2.1.64+
Bug Report: Custom Provider Authentication Broken in Claude Code 2.1.64+
Summary
Custom provider authentication (e.g., Moonshot/Kimi API) stops working after upgrading from Claude Code 2.1.63 to 2.1.64+. The error manifests as invalid_request_error or Not logged in · Please run /login despite having valid API credentials configured.
Environment
- Claude Code Version: 2.1.64 - 2.1.69 (broken), 2.1.63 (working)
- OS: macOS 26.3 (Darwin 25.3.0)
- Node.js: v25.6.1
- npm: 11.10.0
Reproduction Steps
- Configure custom provider environment variables:
export ANTHROPIC_MODEL=kimi-for-coding
export ANTHROPIC_API_KEY=<valid-kimi-api-key>
export ANTHROPIC_BASE_URL=https://api.moonshot.cn/v1
- Install Claude Code 2.1.64 or later:
npm install -g @anthropic-ai/claude-code@2.1.69
- Start a session:
claude
- Send any message to trigger API call
Expected Behavior
API calls to custom provider should succeed with valid credentials, as it did in version 2.1.63.
Actual Behavior
Two types of errors occur:
Error 1: Invalid Request Error
API Error: 400 {"error":{"type":"invalid_request_error","message":"Invalid request Error"},"type":"error"}
Error 2: Authentication Failed
Not logged in · Please run /login
Evidence
Version 2.1.63 (Working)
- Session log:
b7d5c3e2-a35c-4e96-9b49-54d6a215e8c9.jsonl - Date: March 1, 2026
- Model calls:
kimi-for-coding- 238 successful calls - Errors: 0
Version 2.1.69 (Broken)
- Session logs from March 5, 2026:
964c4114-7202-4563-969b-e589673b3e44.jsonl-invalid_request_errore008b836-b044-4e99-916c-0fbd9bb740e8.jsonl-Not logged in5e085f04-45b9-4fe5-90ff-f543b68ee057.jsonl-Not logged in
Key Observation
ToolSearch (deferred tool loading) works correctly. The error occurs after ToolSearch completes, when the model attempts to continue generating the response. This suggests the issue is in the API authentication layer, not the tool system.
Timeline from session 964c4114:
05:51:57.529 - ToolSearch("select:Bash") → SUCCESS
05:51:57.789 - ToolSearch("select:Glob") → SUCCESS
05:51:58.008 - ToolSearch("select:Read") → SUCCESS
05:51:58.394 - API call → 400 invalid_request_error
Workaround
Downgrade to version 2.1.63:
npm uninstall -g @anthropic-ai/claude-code
npm install -g @anthropic-ai/claude-code@2.1.63
Regression Analysis
Based on npm release timestamps:
| Version | Release Date (UTC) | Status |
|---------|-------------------|--------|
| 2.1.63 | 2026-02-28 02:43 | ✅ Working |
| 2.1.64 | 2026-03-03 03:19 | ❌ Broken |
| 2.1.66 | 2026-03-04 00:19 | ❌ Broken |
| 2.1.67 | 2026-03-04 05:31 | ❌ Broken |
| 2.1.68 | 2026-03-04 09:20 | ❌ Broken |
| 2.1.69 | 2026-03-04 21:46 | ❌ Broken |
The breaking change was introduced in version 2.1.64 (March 3, 2026).
Possible Causes
- Changes to authentication header handling for custom providers
- Modifications to how
ANTHROPIC_API_KEYis passed to non-Anthropic endpoints - New validation logic that rejects custom provider configurations
Request
Please investigate and fix the custom provider authentication in upcoming releases, or document any required changes to the configuration format.
---
Reporter: User
Date: 2026-03-05
Affected Providers: Moonshot/Kimi API (likely affects other custom providers using ANTHROPIC_BASE_URL)
This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗