Skip to content

add auto-bedrock support based on bedrock/provider.model-name#1617

Merged
pirate merged 3 commits intomainfrom
auto-bedrock-support
Jan 27, 2026
Merged

add auto-bedrock support based on bedrock/provider.model-name#1617
pirate merged 3 commits intomainfrom
auto-bedrock-support

Conversation

@pirate
Copy link
Member

@pirate pirate commented Jan 27, 2026

why

Fixes: browserbase/stagehand-go#43

Adds automatic bedrock AI SDK client support when modelName ~= 'bedrock/...'

what changed

test plan


Summary by cubic

Adds automatic Amazon Bedrock support by routing models named bedrock/{provider}.{model} to the Bedrock client. This enables zero-API-key setup using your AWS credentials.

  • New Features

    • Route bedrock/... model names to @ai-sdk/amazon-bedrock.
    • Treat Bedrock as no-API-key provider (uses AWS IAM/default credentials).
    • Example usage: bedrock/anthropic.claude-3.
  • Dependencies

    • Added @ai-sdk/amazon-bedrock as an optional dependency.

Written for commit e1d7c4c. Summary will update on new commits. Review in cubic

@changeset-bot
Copy link

changeset-bot bot commented Jan 27, 2026

⚠️ No Changeset found

Latest commit: e1d7c4c

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

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

No issues found across 4 files

Confidence score: 5/5

  • Automated review surfaced no issues in the provided summaries.
  • No files require special attention.
Architecture diagram
sequenceDiagram
    participant User as Client Code
    participant Factory as LLMProvider.ts
    participant Utils as utils.ts
    participant SDK as @ai-sdk/amazon-bedrock
    participant AWS as AWS Cloud

    Note over User, AWS: NEW: Bedrock Client Initialization

    User->>Factory: init("bedrock/anthropic.claude-3")
    Factory->>Factory: Parse provider string ("bedrock")

    Factory->>Utils: checkApiKey("bedrock")
    
    alt NEW: "bedrock" in providersWithoutApiKey
        Utils->>Utils: Skip Env Var validation
        Note right of Utils: Auth relies on standard AWS environment<br/>(AWS_PROFILE or AWS_ACCESS_KEY_ID)
        Utils-->>Factory: Validated (No Key Req)
    else Other Provider (e.g. openai)
        Utils->>Utils: Check specific Env Var (OPENAI_API_KEY)
        Utils-->>Factory: Validated (Key Found)
    end

    Factory->>Factory: Lookup provider in AISDKProviders
    Factory->>SDK: NEW: createAmazonBedrock() / bedrock object
    SDK-->>Factory: Provider Instance
    Factory-->>User: LLMClient Wrapper

    Note over User, AWS: Runtime Interaction

    User->>Factory: generate(...)
    Factory->>SDK: streamText / generateText
    SDK->>AWS: Invoke Model (via AWS SDK Creds)
    AWS-->>SDK: AI Response
    SDK-->>User: Result
Loading

@greptile-apps
Copy link
Contributor

greptile-apps bot commented Jan 27, 2026

Greptile Overview

Greptile Summary

Added automatic AWS Bedrock support for model names following the bedrock/provider.model-name pattern, mirroring the existing implementation for Ollama.

Key changes:

  • Imported bedrock and createAmazonBedrock from @ai-sdk/amazon-bedrock in LLMProvider.ts:21
  • Registered bedrock provider in both AISDKProviders (line 38) and AISDKProvidersWithAPIKey (line 54) dictionaries
  • Added bedrock to providersWithoutApiKey set in utils.ts:698 to skip API key validation warnings
  • Added @ai-sdk/amazon-bedrock v4.0.31 as an optional dependency

The implementation follows the established pattern used for Ollama in PR #1504, enabling users to specify models like bedrock/amazon.nova-pro-latest without manually creating a custom client. Bedrock uses AWS credentials from the environment rather than requiring an explicit API key, similar to Ollama's local-only nature.

Confidence Score: 5/5

  • Safe to merge - straightforward provider integration following established patterns
  • The changes mirror the proven Ollama implementation from PR Fix ollama support with AI SDK #1504, use optional dependencies correctly, and require no breaking changes. All modifications are additive and follow the existing architectural patterns for AI SDK provider registration.
  • No files require special attention

Important Files Changed

Filename Overview
packages/core/lib/v3/llm/LLMProvider.ts Added bedrock provider imports and registered it in AISDKProviders and AISDKProvidersWithAPIKey dictionaries
packages/core/lib/utils.ts Added bedrock to providersWithoutApiKey set to skip API key requirement validation
packages/core/package.json Added @ai-sdk/amazon-bedrock as optional dependency

Sequence Diagram

sequenceDiagram
    participant User
    participant Stagehand
    participant LLMProvider
    participant getAISDKLanguageModel
    participant BedrockSDK as @ai-sdk/amazon-bedrock

    User->>Stagehand: new Stagehand({ model: "bedrock/nova-pro" })
    Stagehand->>LLMProvider: getClient("bedrock/nova-pro")
    LLMProvider->>LLMProvider: Parse modelName ("bedrock/nova-pro")
    LLMProvider->>LLMProvider: Extract subProvider="bedrock", subModelName="nova-pro"
    LLMProvider->>getAISDKLanguageModel: getAISDKLanguageModel("bedrock", "nova-pro", clientOptions)
    
    alt clientOptions has valid values
        getAISDKLanguageModel->>getAISDKLanguageModel: Use AISDKProvidersWithAPIKey["bedrock"]
        getAISDKLanguageModel->>BedrockSDK: createAmazonBedrock(clientOptions)
        BedrockSDK-->>getAISDKLanguageModel: customProvider
        getAISDKLanguageModel->>getAISDKLanguageModel: customProvider("nova-pro")
    else no clientOptions or all undefined/null
        getAISDKLanguageModel->>getAISDKLanguageModel: Use AISDKProviders["bedrock"]
        getAISDKLanguageModel->>BedrockSDK: bedrock("nova-pro")
    end
    
    getAISDKLanguageModel-->>LLMProvider: languageModel
    LLMProvider->>LLMProvider: new AISdkClient({ model: languageModel })
    LLMProvider-->>Stagehand: LLMClient instance
    Stagehand-->>User: Initialized with Bedrock support
Loading

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

No files reviewed, no comments

Edit Code Review Agent Settings | Greptile

@github-actions
Copy link
Contributor

github-actions bot commented Jan 27, 2026

✱ Stainless preview builds

This PR will update the stagehand SDKs with the following commit message.

feat: add auto-bedrock support based on bedrock/provider.model-name
⚠️ stagehand-csharp studio · code

There was a regression in your SDK.
generate ⚠️lint ❗test ✅

stagehand-go studio · code

Your SDK built successfully.
generate ✅lint ✅test ✅

go get github.com/stainless-sdks/stagehand-go@1bd5e501ba590c75662b3abd0065151ad707b108
stagehand-python studio · conflict

There was a conflict between your custom code and your generated changes.
You don't need to resolve this conflict right now, but you will need to resolve it for your changes to be released to your users. Read more about why this happened here.

stagehand-openapi studio · code

Your SDK built successfully.
generate ✅lint ⏳test ⏳

⚠️ stagehand-typescript studio · code

There was a regression in your SDK.
generate ✅build ✅lint ✅test ❗

npm install https://pkg.stainless.com/s/stagehand-typescript/ac6b84fb7a76aff648b6873797071a6b36dd1f3b/dist.tar.gz
stagehand-kotlin studio

Code was not generated because there was a fatal error.

stagehand-java studio · conflict

There was a conflict between your custom code and your generated changes.
You don't need to resolve this conflict right now, but you will need to resolve it for your changes to be released to your users. Read more about why this happened here.

stagehand-php studio · code

Your SDK built successfully.
generate ✅lint ✅test ✅

stagehand-ruby studio · code

Your SDK built successfully.
generate ✅lint ✅test ✅

⏳ These are partial results; builds are still running.


This comment is auto-generated by GitHub Actions and is automatically kept up to date as you push.
If you push custom code to the preview branch, re-run this workflow to update the comment.
Last updated: 2026-01-27 17:51:04 UTC

@pirate pirate merged commit fd744ad into main Jan 27, 2026
29 checks passed
shrey150 added a commit that referenced this pull request Feb 25, 2026
…1759)

## Summary
- Adds `"bedrock"` to the `provider` enum in `ModelConfigObjectSchema` and `AgentConfigSchema` (Zod schemas in `packages/core/lib/v3/types/public/api.ts`)
- Regenerates `packages/server/openapi.v3.yaml` via `pnpm gen:openapi`

## Context
Bedrock was added to `AISDK_PROVIDERS` and `LLMProvider` in PRs #1604 and #1617, but the Zod schemas that feed the OpenAPI spec (and ultimately the Stainless-generated SDKs) were never updated. This means the Python/Go/etc. SDK type definitions don't include `"bedrock"` as a valid provider option.

Companion PR in bb/core: browserbase/core#7668

## Test plan
- [x] `pnpm gen:openapi` produces updated spec with `bedrock` in all 4 provider enum locations
- [ ] Stainless picks up the OpenAPI change and regenerates SDKs with `bedrock` in the `provider` literal type

🤖 Generated with [Claude Code](https://claude.com/claude-code)

<!-- This is an auto-generated description by cubic. -->
---
## Summary by cubic
Add "bedrock" to provider enums in ModelConfigObjectSchema/AgentConfigSchema and regenerate the OpenAPI spec so SDKs accept it and stay in sync with AISDK_PROVIDERS/LLMProvider. Also update AgentType to include "bedrock" to fix a server build type mismatch, and add a patch changeset to publish and unblock Python/Go SDK type generation.

<sup>Written for commit 88e3372. Summary will update on new commits. <a href="https://cubic.dev/pr/browserbase/stagehand/pull/1759">Review in cubic</a></sup>

<!-- End of auto-generated description by cubic. -->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

AWS Support: Models through Bedrock

2 participants