fix(models): normalize bare-host ANTHROPIC_BASE_URL in getAnthropicProvider#62
Open
slusset wants to merge 1 commit into
Open
fix(models): normalize bare-host ANTHROPIC_BASE_URL in getAnthropicProvider#62slusset wants to merge 1 commit into
slusset wants to merge 1 commit into
Conversation
…ovider AI coding harnesses (Claude Code, Cursor) export ANTHROPIC_BASE_URL as a bare host (https://api.anthropic.com, no /v1) for their own runtime. @ai-sdk/anthropic prefers this env var over its https://api.anthropic.com/v1 default and uses it verbatim, so getAnthropicProvider()'s createAnthropic({ apiKey }) call (no baseURL) silently inherits the bare host and every Anthropic request 404s at .../messages. Other providers (e.g. Gemini) keep working, so consensus runs look half-broken with nothing pointing at the env. Normalize the env value (append /v1 when it lacks a version path) and pass it explicitly as baseURL. Unset env returns undefined so the provider keeps its own default. Scoped to the direct path; the gateway path already sets baseURL. Closes bug0inc#57. See vercel/ai#15542 for the upstream SDK issue. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #57.
Problem. AI coding harnesses (Claude Code, Cursor) export
ANTHROPIC_BASE_URLas a bare host (https://api.anthropic.com, no/v1).@ai-sdk/anthropicprefers this env var over its…/v1default, sogetAnthropicProvider()'screateAnthropic({ apiKey })(nobaseURL) inherits the bare host and every Anthropic request 404s at…/messages. Gemini keeps working, so consensus runs look half-broken with nothing pointing at the env var.Fix. Normalize the env value (append
/v1when it lacks a version path) and pass it explicitly asbaseURL. Unset env →undefined, so the provider keeps its own default. Scoped to the direct path; the gateway path already setsbaseURL.Tests. New
src/__tests__/models.test.tscovers bare host, trailing slash, already-/v1,/v1/, custom proxy, and unset.pnpm build/lint/test(172) green.Upstream SDK issue: vercel/ai#15542.