add support for custom baseurl in openai provider - #1025
Conversation
🦋 Changeset detectedLatest commit: f9e669b The changes in this PR will be included in the next version bump. Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
There was a problem hiding this comment.
Greptile Summary
This PR adds support for custom baseURL configuration in the OpenAI provider within Stagehand's LLM infrastructure. The change allows users to connect to OpenAI-compatible APIs hosted at different endpoints, such as local Ollama instances, Azure OpenAI services, or other custom OpenAI providers.
The implementation modifies the LLMProvider.ts file by:
- Adding an optional
baseURLparameter to thegetAISDKLanguageModelfunction - Creating a conditional
providerConfigobject that includes thebaseURLwhen provided - Passing the
baseURLfromclientOptionsthrough to the AI SDK provider creation
The change maintains backward compatibility by making baseURL optional and uses conditional object construction to avoid passing undefined values to providers that don't support custom base URLs. This enhancement integrates with Stagehand's existing AI SDK infrastructure and aligns with the library's goal of supporting various OpenAI-compatible APIs.
PR Description Notes:
- Minor typo: "cusotm" should be "custom" in the why section
Confidence score: 2/5
- This PR has potential type safety issues that could cause compilation errors in production
- Score lowered due to apparent mismatch between AISDKCustomProvider type definition and the new baseURL parameter being passed
- Pay close attention to
lib/llm/LLMProvider.tsand verify type definitions are updated accordingly
1 file reviewed, no comments
|
🔄 Feature Parity Issue Created An issue has been automatically created in the Python SDK repository to track parity implementation: |
|
changeset 🙏 |
This PR was opened by the [Changesets release](https://github.com/changesets/action) GitHub action. When you're ready to do a release, you can merge this and the packages will be published to npm automatically. If you're not ready to do a release yet, that's fine, whenever you add more changesets to main, this PR will be updated. # Releases ## @browserbasehq/stagehand@2.5.0 ### Minor Changes - [#981](#981) [`8244ab2`](8244ab2) Thanks [@sameelarif](https://github.com/sameelarif)! - Added support for `stagehand.agent` to interact with MCP servers as well as custom tools to be passed in. For more information, reference the [MCP integrations documentation](https://docs.stagehand.dev/best-practices/mcp-integrations) ### Patch Changes - [#959](#959) [`09b5e1e`](09b5e1e) Thanks [@filip-michalsky](https://github.com/filip-michalsky)! - add webvoyager evals - [#1049](#1049) [`e3734b9`](e3734b9) Thanks [@miguelg719](https://github.com/miguelg719)! - Support local MCP server connections - [#1025](#1025) [`be85b19`](be85b19) Thanks [@tkattkat](https://github.com/tkattkat)! - add support for custom baseUrl within openai provider - [#1040](#1040) [`88d1565`](88d1565) Thanks [@miguelg719](https://github.com/miguelg719)! - Allow OpenAI CUA to take in an optional baseURL - [#1046](#1046) [`ab5d6ed`](ab5d6ed) Thanks [@tkattkat](https://github.com/tkattkat)! - Add support for gpt-5 in operator agent ## @browserbasehq/stagehand-evals@1.0.9 ### Patch Changes - Updated dependencies \[[`09b5e1e`](09b5e1e), [`e3734b9`](e3734b9), [`8244ab2`](8244ab2), [`be85b19`](be85b19), [`88d1565`](88d1565), [`ab5d6ed`](ab5d6ed)]: - @browserbasehq/stagehand@2.5.0 ## @browserbasehq/stagehand-examples@1.0.9 ### Patch Changes - Updated dependencies \[[`09b5e1e`](09b5e1e), [`e3734b9`](e3734b9), [`8244ab2`](8244ab2), [`be85b19`](be85b19), [`88d1565`](88d1565), [`ab5d6ed`](ab5d6ed)]: - @browserbasehq/stagehand@2.5.0 Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
This PR was opened by the [Changesets release](https://github.com/changesets/action) GitHub action. When you're ready to do a release, you can merge this and the packages will be published to npm automatically. If you're not ready to do a release yet, that's fine, whenever you add more changesets to main, this PR will be updated. # Releases ## @browserbasehq/stagehand@2.5.0 ### Minor Changes - [#981](browserbase/stagehand#981) [`8244ab2`](browserbase/stagehand@8244ab2) Thanks [@sameelarif](https://github.com/sameelarif)! - Added support for `stagehand.agent` to interact with MCP servers as well as custom tools to be passed in. For more information, reference the [MCP integrations documentation](https://docs.stagehand.dev/best-practices/mcp-integrations) ### Patch Changes - [#959](browserbase/stagehand#959) [`09b5e1e`](browserbase/stagehand@09b5e1e) Thanks [@filip-michalsky](https://github.com/filip-michalsky)! - add webvoyager evals - [#1049](browserbase/stagehand#1049) [`e3734b9`](browserbase/stagehand@e3734b9) Thanks [@miguelg719](https://github.com/miguelg719)! - Support local MCP server connections - [#1025](browserbase/stagehand#1025) [`be85b19`](browserbase/stagehand@be85b19) Thanks [@tkattkat](https://github.com/tkattkat)! - add support for custom baseUrl within openai provider - [#1040](browserbase/stagehand#1040) [`88d1565`](browserbase/stagehand@88d1565) Thanks [@miguelg719](https://github.com/miguelg719)! - Allow OpenAI CUA to take in an optional baseURL - [#1046](browserbase/stagehand#1046) [`ab5d6ed`](browserbase/stagehand@ab5d6ed) Thanks [@tkattkat](https://github.com/tkattkat)! - Add support for gpt-5 in operator agent ## @browserbasehq/stagehand-evals@1.0.9 ### Patch Changes - Updated dependencies \[[`09b5e1e`](browserbase/stagehand@09b5e1e), [`e3734b9`](browserbase/stagehand@e3734b9), [`8244ab2`](browserbase/stagehand@8244ab2), [`be85b19`](browserbase/stagehand@be85b19), [`88d1565`](browserbase/stagehand@88d1565), [`ab5d6ed`](browserbase/stagehand@ab5d6ed)]: - @browserbasehq/stagehand@2.5.0 ## @browserbasehq/stagehand-examples@1.0.9 ### Patch Changes - Updated dependencies \[[`09b5e1e`](browserbase/stagehand@09b5e1e), [`e3734b9`](browserbase/stagehand@e3734b9), [`8244ab2`](browserbase/stagehand@8244ab2), [`be85b19`](browserbase/stagehand@be85b19), [`88d1565`](browserbase/stagehand@88d1565), [`ab5d6ed`](browserbase/stagehand@ab5d6ed)]: - @browserbasehq/stagehand@2.5.0 Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
# why currently, we do not support passing cusotm baseurls for the openai provider # what changed baseUrl can now optionally be passed to the openai client within ai sdk # test plan tested locally
This PR was opened by the [Changesets release](https://github.com/changesets/action) GitHub action. When you're ready to do a release, you can merge this and the packages will be published to npm automatically. If you're not ready to do a release yet, that's fine, whenever you add more changesets to main, this PR will be updated. # Releases ## @browserbasehq/stagehand@2.5.0 ### Minor Changes - [browserbase#981](browserbase#981) [`8244ab2`](browserbase@8244ab2) Thanks [@sameelarif](https://github.com/sameelarif)! - Added support for `stagehand.agent` to interact with MCP servers as well as custom tools to be passed in. For more information, reference the [MCP integrations documentation](https://docs.stagehand.dev/best-practices/mcp-integrations) ### Patch Changes - [browserbase#959](browserbase#959) [`09b5e1e`](browserbase@09b5e1e) Thanks [@filip-michalsky](https://github.com/filip-michalsky)! - add webvoyager evals - [browserbase#1049](browserbase#1049) [`e3734b9`](browserbase@e3734b9) Thanks [@miguelg719](https://github.com/miguelg719)! - Support local MCP server connections - [browserbase#1025](browserbase#1025) [`be85b19`](browserbase@be85b19) Thanks [@tkattkat](https://github.com/tkattkat)! - add support for custom baseUrl within openai provider - [browserbase#1040](browserbase#1040) [`88d1565`](browserbase@88d1565) Thanks [@miguelg719](https://github.com/miguelg719)! - Allow OpenAI CUA to take in an optional baseURL - [browserbase#1046](browserbase#1046) [`ab5d6ed`](browserbase@ab5d6ed) Thanks [@tkattkat](https://github.com/tkattkat)! - Add support for gpt-5 in operator agent ## @browserbasehq/stagehand-evals@1.0.9 ### Patch Changes - Updated dependencies \[[`09b5e1e`](browserbase@09b5e1e), [`e3734b9`](browserbase@e3734b9), [`8244ab2`](browserbase@8244ab2), [`be85b19`](browserbase@be85b19), [`88d1565`](browserbase@88d1565), [`ab5d6ed`](browserbase@ab5d6ed)]: - @browserbasehq/stagehand@2.5.0 ## @browserbasehq/stagehand-examples@1.0.9 ### Patch Changes - Updated dependencies \[[`09b5e1e`](browserbase@09b5e1e), [`e3734b9`](browserbase@e3734b9), [`8244ab2`](browserbase@8244ab2), [`be85b19`](browserbase@be85b19), [`88d1565`](browserbase@88d1565), [`ab5d6ed`](browserbase@ab5d6ed)]: - @browserbasehq/stagehand@2.5.0
why
currently, we do not support passing cusotm baseurls for the openai provider
what changed
baseUrl can now optionally be passed to the openai client within ai sdk
test plan
tested locally