API Error 400 with custom model via ANTHROPIC_BASE_URL when plugins are loaded

Resolved 💬 6 comments Opened May 29, 2026 by wang1xiang Closed Jul 1, 2026

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:

  1. --bare mode works perfectly - When all plugins are disabled, Claude Code connects to the custom API endpoint without issues.
  1. 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-8 that aren't available on the custom endpoint
  • Request body formats that the custom endpoint doesn't support
  1. 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

  1. 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>
``

  1. Create a settings file with plugins enabled:

``json
{
"model": "qwen3.6-plus",
"enabledPlugins": {
"typescript-lsp@claude-plugins-official": true,
"superpowers@claude-plugins-official": true
}
}
``

  1. Start Claude Code:

``bash
claude --settings ~/.claude/settings-test.json
``

  1. 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:

  1. Respect the configured model for all API requests (including plugin-related ones)
  2. Provide a way to disable plugin-specific API calls when using custom endpoints
  3. 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

View original on GitHub ↗

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