claude-code - 💡(How to fix) Fix ANTHROPIC_DEFAULT_*_MODEL env vars from settings.json injected in OAuth mode but BASE_URL is not, causing tool failures with third-party API model names [1 participants]

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…
GitHub stats
anthropics/claude-code#48365Fetched 2026-04-16 07:02:16
View on GitHub
Comments
0
Participants
1
Timeline
4
Reactions
0
Author
Participants
Timeline (top)
labeled ×4

When using Claude Code via the desktop app (OAuth authentication), environment variables from ~/.claude/settings.json's env field are partially respected in an inconsistent way:

  • ANTHROPIC_DEFAULT_HAIKU_MODELis injected and used by internal tools (e.g. WebFetch)
  • ANTHROPIC_BASE_URLis not used (overridden by OAuth routing)

This causes tools like WebFetch/WebSearch to fail when the user has configured third-party API model names that are only valid on their custom BASE_URL.

Root Cause

When using Claude Code via the desktop app (OAuth authentication), environment variables from ~/.claude/settings.json's env field are partially respected in an inconsistent way:

  • ANTHROPIC_DEFAULT_HAIKU_MODELis injected and used by internal tools (e.g. WebFetch)
  • ANTHROPIC_BASE_URLis not used (overridden by OAuth routing)

This causes tools like WebFetch/WebSearch to fail when the user has configured third-party API model names that are only valid on their custom BASE_URL.

Code Example

"env": {
     "ANTHROPIC_BASE_URL": "https://third-party-api.example.com",
     "ANTHROPIC_DEFAULT_HAIKU_MODEL": "claude-haiku-4-5-20251001-custom"
   }
RAW_BUFFERClick to expand / collapse

Summary

When using Claude Code via the desktop app (OAuth authentication), environment variables from ~/.claude/settings.json's env field are partially respected in an inconsistent way:

  • ANTHROPIC_DEFAULT_HAIKU_MODELis injected and used by internal tools (e.g. WebFetch)
  • ANTHROPIC_BASE_URLis not used (overridden by OAuth routing)

This causes tools like WebFetch/WebSearch to fail when the user has configured third-party API model names that are only valid on their custom BASE_URL.

Steps to Reproduce

  1. Set in ~/.claude/settings.json:
    "env": {
      "ANTHROPIC_BASE_URL": "https://third-party-api.example.com",
      "ANTHROPIC_DEFAULT_HAIKU_MODEL": "claude-haiku-4-5-20251001-custom"
    }
  2. Log in via OAuth in the desktop app's Code feature
  3. Use WebFetch or WebSearch tool

Expected Behavior

Either:

  • OAuth mode ignores ALL env vars that depend on BASE_URL (including model name overrides), OR
  • OAuth mode respects BASE_URL and routes tool sub-calls accordingly

Actual Behavior

WebFetch reads ANTHROPIC_DEFAULT_HAIKU_MODEL = claude-haiku-4-5-20251001-custom but routes to Anthropic's official API (via OAuth), which doesn't recognize the third-party model name:

There's an issue with the selected model (claude-haiku-4-5-20251001-custom)

Environment

  • Claude Code version: 2.1.109
  • Platform: Windows 11
  • Auth mode: OAuth (desktop app)

extent analysis

TL;DR

To fix the inconsistent environment variable handling, consider modifying the OAuth authentication flow to respect the ANTHROPIC_BASE_URL environment variable or adjusting the tool configuration to use the official API model names.

Guidance

  • Verify that the ANTHROPIC_BASE_URL environment variable is correctly set in the ~/.claude/settings.json file and that it is not being overridden by any other configuration settings.
  • Check if the OAuth authentication flow can be modified to respect the ANTHROPIC_BASE_URL environment variable, allowing tools like WebFetch and WebSearch to route sub-calls accordingly.
  • Consider adding a fallback or default behavior for tools that rely on the ANTHROPIC_DEFAULT_HAIKU_MODEL environment variable, in case the custom model name is not recognized by the official API.
  • Review the documentation for the Claude Code desktop app and OAuth authentication to ensure that environment variables are being handled as expected.

Example

No code snippet is provided as the issue is related to configuration and authentication flow.

Notes

The issue seems to be specific to the OAuth authentication mode in the desktop app, and the fix may require modifications to the authentication flow or tool configuration. Further investigation is needed to determine the root cause and the most suitable solution.

Recommendation

Apply a workaround by adjusting the tool configuration to use official API model names or modifying the OAuth authentication flow to respect the ANTHROPIC_BASE_URL environment variable, as the issue is likely related to the inconsistent handling of environment variables in the OAuth mode.

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 ANTHROPIC_DEFAULT_*_MODEL env vars from settings.json injected in OAuth mode but BASE_URL is not, causing tool failures with third-party API model names [1 participants]