add auto-bedrock support based on bedrock/provider.model-name#1617
add auto-bedrock support based on bedrock/provider.model-name#1617
Conversation
|
There was a problem hiding this comment.
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
Greptile OverviewGreptile SummaryAdded automatic AWS Bedrock support for model names following the Key changes:
The implementation follows the established pattern used for Ollama in PR #1504, enabling users to specify models like Confidence Score: 5/5
Important Files Changed
Sequence DiagramsequenceDiagram
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
|
✱ Stainless preview buildsThis PR will update the ✅ stagehand-go studio · code
⚡ stagehand-python studio · conflict
|
…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. -->
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
Dependencies
Written for commit e1d7c4c. Summary will update on new commits. Review in cubic