feat(provider/gateway): support AI_GATEWAY_BASE_URL env for the base URL#16401
Open
brycedbjork wants to merge 1 commit into
Open
feat(provider/gateway): support AI_GATEWAY_BASE_URL env for the base URL#16401brycedbjork wants to merge 1 commit into
AI_GATEWAY_BASE_URL env for the base URL#16401brycedbjork wants to merge 1 commit into
Conversation
The gateway provider's base URL was only settable via `createGateway({ baseURL })`.
The default/global gateway provider (used to resolve plain `provider/model` strings)
is constructed internally, so callers can't point it at a custom endpoint without
building a provider by hand. Add an `AI_GATEWAY_BASE_URL` fallback, symmetric with
the existing `AI_GATEWAY_API_KEY` env.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
|
||
| const baseURL = | ||
| withoutTrailingSlash(options.baseURL) ?? | ||
| withoutTrailingSlash(options.baseURL ?? process.env.AI_GATEWAY_BASE_URL) ?? |
Contributor
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.
Summary
The Gateway provider's base URL is only configurable via
createGateway({ baseURL }). The default / global gateway provider — the one the AI SDK uses to resolve plainprovider/modelstrings (e.g.generateText({ model: 'anthropic/claude-...' })) — is constructed internally, so callers have no way to point it at a custom endpoint without building a provider by hand and threading it through every call site.This adds an
AI_GATEWAY_BASE_URLenvironment-variable fallback, symmetric with the existingAI_GATEWAY_API_KEYenv, so the gateway endpoint can be overridden process-wide — useful for a self-hosted gateway, a local proxy that injects auth/headers, testing, or enterprise egress.Change
Precedence: explicit
options.baseURL→AI_GATEWAY_BASE_URL→ default. No behavior change when neither is set. The doc comment onGatewayProviderSettings.baseURLis updated to mention the env var, and a changeset is included.