feat(provider/openai): allow configuring base URL via OPENAI_BASE_URL#8990
Merged
gr2m merged 6 commits intovercel:mainfrom Sep 30, 2025
Merged
feat(provider/openai): allow configuring base URL via OPENAI_BASE_URL#8990gr2m merged 6 commits intovercel:mainfrom
gr2m merged 6 commits intovercel:mainfrom
Conversation
Collaborator
|
I confirmed that the official OpenAI SDK supports But it's not documented on their website: We will add support for it but not document it for now, following OpenAI's example |
gr2m
reviewed
Sep 29, 2025
Collaborator
gr2m
left a comment
There was a problem hiding this comment.
can you please follow the checklist of the pull request template? We can move ahead with the change
gr2m
reviewed
Sep 30, 2025
vercel-ai-sdk bot
pushed a commit
that referenced
this pull request
Sep 30, 2025
…#8990) ## Background Some deployments need to target an OpenAI-compatible endpoint (e.g. self-hosted proxy, regional gateway). The OpenAI provider currently hardcodes the API base URL, which makes this inconvenient. ## Summary - Add support for configuring the API base URL via the `OPENAI_BASE_URL` environment variable and the `baseURL` option on the provider. - Continue to default to `https://api.openai.com/v1` when not provided. - Applies consistently across chat, completion, responses, embeddings, image, transcription, and speech models. ## Manual Verification - Set `OPENAI_BASE_URL` to a custom endpoint (e.g. `https://api.openai-proxy.example/v1`). - Initialize via `createOpenAI()` and call `openai.responses(/* modelId */)`; requests target the configured host. - Unset the env var and omit `baseURL`; requests fall back to `https://api.openai.com/v1`. - Also verified that an explicit `baseURL` option takes precedence over the env var. ## Related Issues Fixes #8564 --------- Co-authored-by: Gregor Martynus <39992+gr2m@users.noreply.github.com>
Contributor
|
✅ Backport PR created: #9052 |
4 tasks
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.
Background
Some deployments need to target an OpenAI-compatible endpoint (e.g. self-hosted proxy, regional gateway). The OpenAI provider currently hardcodes the API base URL, which makes this inconvenient.
Summary
OPENAI_BASE_URLenvironment variable and thebaseURLoption on the provider.https://api.openai.com/v1when not provided.Manual Verification
OPENAI_BASE_URLto a custom endpoint (e.g.https://api.openai-proxy.example/v1).createOpenAI()and callopenai.responses(/* modelId */); requests target the configured host.baseURL; requests fall back tohttps://api.openai.com/v1.baseURLoption takes precedence over the env var.Checklist
pnpm changesetin the project root)pnpm prettier-fixin the project root)Future Work
OPENAI_BASE_URLalongside other provider configuration in the docs.Related Issues
Fixes #8564