Skip to content

add support for custom baseurl in openai provider - #1025

Merged
tkattkat merged 4 commits into
mainfrom
add-support-for-custom-baseurl-in-openai-provider
Aug 28, 2025
Merged

add support for custom baseurl in openai provider#1025
tkattkat merged 4 commits into
mainfrom
add-support-for-custom-baseurl-in-openai-provider

Conversation

@tkattkat

Copy link
Copy Markdown
Collaborator

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

@changeset-bot

changeset-bot Bot commented Aug 26, 2025

Copy link
Copy Markdown

🦋 Changeset detected

Latest 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

@greptile-apps greptile-apps Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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 baseURL parameter to the getAISDKLanguageModel function
  • Creating a conditional providerConfig object that includes the baseURL when provided
  • Passing the baseURL from clientOptions through 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.ts and verify type definitions are updated accordingly

1 file reviewed, no comments

Edit Code Review Bot Settings | Greptile

@miguelg719 miguelg719 added the parity To note required feature parity in client SDKs label Aug 27, 2025
@stagehand-parity-bot

Copy link
Copy Markdown

🔄 Feature Parity Issue Created

An issue has been automatically created in the Python SDK repository to track parity implementation:
browserbase/stagehand-python#189

Comment thread lib/StagehandPage.ts Outdated
@miguelg719

Copy link
Copy Markdown
Collaborator

changeset 🙏

@tkattkat
tkattkat merged commit be85b19 into main Aug 28, 2025
15 checks passed
miguelg719 pushed a commit that referenced this pull request Sep 4, 2025
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>
michaelfp930-WB added a commit to michaelfp930-WB/stagehand that referenced this pull request Jan 12, 2026
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>
felipeofdev-ai pushed a commit to felipeofdev-ai/stagehand that referenced this pull request Aug 4, 2026
# 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
felipeofdev-ai pushed a commit to felipeofdev-ai/stagehand that referenced this pull request Aug 4, 2026
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

parity To note required feature parity in client SDKs

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants