API Error 400 with custom model via ANTHROPIC_BASE_URL when plugins are loaded
Issue Description
When using Claude Code with a custom API endpoint (百炼 DashScope proxy) via environment variables ANTHROPIC_BASE_URL and ANTHROPIC_MODEL, the following error occurs on new sessions:
API Error: 400 Request body format invalid
The error also manifests as model resolution failures:
API Error: 400 model 'claude-opus-4-8' is not supported.Model 'qwen3.6-plus' is not available. Your organization restricts model selection.
Root Cause Analysis
Through systematic debugging, I identified that:
--baremode works perfectly - When all plugins are disabled, Claude Code connects to the custom API endpoint without issues.
- Plugin loading triggers incompatible API requests - When plugins are loaded (any plugin: LSP, superpowers, claude-mem, etc.), Claude Code sends additional API requests that use:
- Model names like
claude-opus-4-8that aren't available on the custom endpoint - Request body formats that the custom endpoint doesn't support
- Configuration method matters - Using
--settings <file>to specify configuration triggers the error, while relying on environment variables (ANTHROPIC_BASE_URL,ANTHROPIC_MODEL) works correctly in the current session.
Environment
- Claude Code version: 2.1.156
- Custom API endpoint:
https://coding.dashscope.aliyuncs.com/apps/anthropic(百炼 DashScope proxy) - Custom model:
qwen3.6-plus - OS: macOS (Darwin 25.4.0)
- Node.js: v18.18.0
Reproduction Steps
- Set environment variables:
``bash``
export ANTHROPIC_BASE_URL=https://coding.dashscope.aliyuncs.com/apps/anthropic
export ANTHROPIC_MODEL=qwen3.6-plus
export ANTHROPIC_AUTH_TOKEN=<your-token>
- Create a settings file with plugins enabled:
``json``
{
"model": "qwen3.6-plus",
"enabledPlugins": {
"typescript-lsp@claude-plugins-official": true,
"superpowers@claude-plugins-official": true
}
}
- Start Claude Code:
``bash``
claude --settings ~/.claude/settings-test.json
- Observe error:
API Error: 400 Request body format invalid
Workaround
Using --bare mode works:
claude --bare --settings ~/.claude/settings-test.json
Expected Behavior
Claude Code should either:
- Respect the configured model for all API requests (including plugin-related ones)
- Provide a way to disable plugin-specific API calls when using custom endpoints
- Gracefully handle model unavailability without breaking the entire session
Additional Context
This is a significant issue for users who:
- Use Claude Code with custom API endpoints (common in enterprise/China deployments)
- Rely on plugins for development workflow (LSP, superpowers, memory systems)
- Need both custom models and plugin functionality simultaneously
This issue has 6 comments on GitHub. Read the full discussion on GitHub ↗