ollama - 💡(How to fix) Fix ollama launch claude: fails with API Error 400 when user has CLAUDE_CODE_USE_BEDROCK=1 in Claude Code settings.json

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…

ollama launch claude sets the model name in Claude Code to the pulled local model (e.g. gemma4) but does not override backend routing. If the user has CLAUDE_CODE_USE_BEDROCK=1 set in ~/.claude/settings.json (Anthropic's persistent settings file), every request still routes to AWS Bedrock — not to Ollama — and Bedrock rejects the model name with:

API Error (gemma4): 400 The provided model identifier is invalid.

Error Message

API Error (gemma4): 400 The provided model identifier is invalid. 4. Type any message → API Error (gemma4): 400 The provided model identifier is invalid.

  1. Detect CLAUDE_CODE_USE_BEDROCK / AWS_BEDROCK_* / non-Anthropic model in ~/.claude/settings.json and warn the user that local model routing will not work, or

Root Cause

ollama launch claude only sets --model gemma4 when spawning Claude Code. It does not:

  • Set ANTHROPIC_BASE_URL=http://127.0.0.1:11434
  • Unset / override CLAUDE_CODE_USE_BEDROCK

Claude Code's settings.json env block is loaded before CLI args and environment variables passed to the process, so CLAUDE_CODE_USE_BEDROCK=1 wins regardless of what the shell environment contains. Passing CLAUDE_CODE_USE_BEDROCK="" ANTHROPIC_BASE_URL=... claude from the terminal also fails because settings.json re-injects the Bedrock variable.

Ollama itself works fine — curl http://127.0.0.1:11434/v1/chat/completions with gemma4 responds correctly.

Fix Action

Workaround

None available via CLI alone. The only fix is to manually edit ~/.claude/settings.json and remove or toggle CLAUDE_CODE_USE_BEDROCK before running ollama launch claude, then restore it afterward.

Code Example

API Error (gemma4): 400 The provided model identifier is invalid.

---

{
     "env": {
       "CLAUDE_CODE_USE_BEDROCK": "1",
       "AWS_REGION": "us-east-1"
     },
     "model": "us.anthropic.claude-sonnet-4-6"
   }
RAW_BUFFERClick to expand / collapse

Summary

ollama launch claude sets the model name in Claude Code to the pulled local model (e.g. gemma4) but does not override backend routing. If the user has CLAUDE_CODE_USE_BEDROCK=1 set in ~/.claude/settings.json (Anthropic's persistent settings file), every request still routes to AWS Bedrock — not to Ollama — and Bedrock rejects the model name with:

API Error (gemma4): 400 The provided model identifier is invalid.

Steps to reproduce

  1. Have ~/.claude/settings.json containing:
    {
      "env": {
        "CLAUDE_CODE_USE_BEDROCK": "1",
        "AWS_REGION": "us-east-1"
      },
      "model": "us.anthropic.claude-sonnet-4-6"
    }
  2. ollama pull gemma4
  3. ollama launch claude (installs gemma4 and launches Claude Code)
  4. Type any message → API Error (gemma4): 400 The provided model identifier is invalid.

Root cause

ollama launch claude only sets --model gemma4 when spawning Claude Code. It does not:

  • Set ANTHROPIC_BASE_URL=http://127.0.0.1:11434
  • Unset / override CLAUDE_CODE_USE_BEDROCK

Claude Code's settings.json env block is loaded before CLI args and environment variables passed to the process, so CLAUDE_CODE_USE_BEDROCK=1 wins regardless of what the shell environment contains. Passing CLAUDE_CODE_USE_BEDROCK="" ANTHROPIC_BASE_URL=... claude from the terminal also fails because settings.json re-injects the Bedrock variable.

Ollama itself works fine — curl http://127.0.0.1:11434/v1/chat/completions with gemma4 responds correctly.

Environment

  • OS: macOS Darwin 25.4.0 (Apple M5 Pro)
  • Ollama version: 0.23.2
  • Claude Code version: 2.1.138
  • Model pulled: gemma4:latest (9.6 GB)

Expected behavior

ollama launch claude should either:

  1. Detect CLAUDE_CODE_USE_BEDROCK / AWS_BEDROCK_* / non-Anthropic model in ~/.claude/settings.json and warn the user that local model routing will not work, or
  2. Pass the necessary env overrides in a way that wins over settings.json (if Claude Code provides a CLI flag to override env vars), or
  3. Document clearly that ollama launch claude is incompatible with Bedrock / non-standard API configurations.

Workaround

None available via CLI alone. The only fix is to manually edit ~/.claude/settings.json and remove or toggle CLAUDE_CODE_USE_BEDROCK before running ollama launch claude, then restore it afterward.

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…

FAQ

Expected behavior

ollama launch claude should either:

  1. Detect CLAUDE_CODE_USE_BEDROCK / AWS_BEDROCK_* / non-Anthropic model in ~/.claude/settings.json and warn the user that local model routing will not work, or
  2. Pass the necessary env overrides in a way that wins over settings.json (if Claude Code provides a CLI flag to override env vars), or
  3. Document clearly that ollama launch claude is incompatible with Bedrock / non-standard API configurations.

Still need to ship something?

×6

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

Back to top recommendations

TRENDING

ollama - 💡(How to fix) Fix ollama launch claude: fails with API Error 400 when user has CLAUDE_CODE_USE_BEDROCK=1 in Claude Code settings.json