claude-code - 💡(How to fix) Fix API Error 400 with custom model via ANTHROPIC_BASE_URL when plugins are loaded

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…

Error Message

API Error: 400 Request body format invalid

Root Cause

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.

  2. 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
  3. 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.

Fix Action

Workaround

Using --bare mode works:

claude --bare --settings ~/.claude/settings-test.json

Code Example

API Error: 400 Request body format invalid

---

export ANTHROPIC_BASE_URL=https://coding.dashscope.aliyuncs.com/apps/anthropic
   export ANTHROPIC_MODEL=qwen3.6-plus
   export ANTHROPIC_AUTH_TOKEN=<your-token>

---

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

---

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

---

claude --bare --settings ~/.claude/settings-test.json
RAW_BUFFERClick to expand / collapse

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.

  2. 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
  3. 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:

    export ANTHROPIC_BASE_URL=https://coding.dashscope.aliyuncs.com/apps/anthropic
    export ANTHROPIC_MODEL=qwen3.6-plus
    export ANTHROPIC_AUTH_TOKEN=<your-token>
  2. Create a settings file with plugins enabled:

    {
      "model": "qwen3.6-plus",
      "enabledPlugins": {
        "typescript-lsp@claude-plugins-official": true,
        "superpowers@claude-plugins-official": true
      }
    }
  3. Start Claude Code:

    claude --settings ~/.claude/settings-test.json
  4. 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

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

claude-code - 💡(How to fix) Fix API Error 400 with custom model via ANTHROPIC_BASE_URL when plugins are loaded