Skip to content

anthropic provider: honor ANTHROPIC_BASE_URL env var#292

Closed
jaylossless wants to merge 1 commit into
NVIDIA:mainfrom
jaylossless:honor-anthropic-base-url
Closed

anthropic provider: honor ANTHROPIC_BASE_URL env var#292
jaylossless wants to merge 1 commit into
NVIDIA:mainfrom
jaylossless:honor-anthropic-base-url

Conversation

@jaylossless

Copy link
Copy Markdown

Summary

The anthropic provider hardcodes base_url to https://api.anthropic.com in create_chat_model, so it can't be pointed at self-hosted gateways, corporate proxies, or Anthropic-compatible endpoints. The openai provider already honors OPENAI_BASE_URL; this brings the anthropic provider to parity by honoring ANTHROPIC_BASE_URL (the same env var the official Anthropic SDK reads).

Change

  • create_chat_model reads ANTHROPIC_BASE_URL from the environment, falling back to the existing api.anthropic.com default.
  • Backward compatible: behavior is unchanged when the env var is unset.

Testing

Pointed the anthropic provider at an Anthropic-compatible Messages endpoint via ANTHROPIC_BASE_URL and confirmed scans complete with tool-use structured output; the default path is unaffected when the var is unset.

🤖 Generated with Claude Code

The anthropic provider hardcodes base_url to https://api.anthropic.com, so it
can't target self-hosted gateways or Anthropic-compatible endpoints. The openai
provider already honors OPENAI_BASE_URL; this brings the anthropic provider to
parity. Behavior is unchanged when ANTHROPIC_BASE_URL is unset.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>

@keshprad keshprad left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good, clean fix. Thanks!

@keshprad

Copy link
Copy Markdown
Member

I will merge and create release sometime by end of day. Thanks!

@keshprad
keshprad self-requested a review July 22, 2026 00:49
@keshprad

Copy link
Copy Markdown
Member

Coming back to this, I see another PR with comprehensive tests. Closing this in favor or #282

@keshprad keshprad closed this Jul 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants