Add support for Amazon Bedrock provider (#1185)
- follows existing patterns for AI SDK to provide Bedrock integration - Uses Bedrock's API token feature for authentication which provides a standard experience - bedrock provided models match the Anthropic provided models (for now) **Disclaimer**: The contributing docs are extremely sparse. I don't actually know how to build this and get this running in Electron ## Testing - AWS Bedrock provider is available for selection <img width="994" height="496" alt="image" src="https://github.com/user-attachments/assets/3cb21fed-9826-40e5-8019-b2b5df5e873b" /> - The provider settings also show the right models and offer the right env variable to use <img width="949" height="862" alt="image" src="https://github.com/user-attachments/assets/8c23d5c8-d84d-4bf7-856a-8dc8d9d6c4b4" /> <!-- This is an auto-generated description by cubic. --> --- ## Summary by cubic Adds AWS Bedrock as a provider so users can run Claude models via Bedrock with API token authentication. The settings now list Bedrock with supported models and a new env var. - New Features - New provider: bedrock using @ai-sdk/amazon-bedrock, wired into model client and schemas. - Models: Claude 4 Sonnet, Claude 3.7 Sonnet, Claude 3.5 Sonnet (Bedrock model IDs). - Settings: shows AWS Bedrock with correct models and env var AWS_BEARER_TOKEN_BEDROCK. - Default region: us-east-1. - Migration - Set AWS_BEARER_TOKEN_BEDROCK with your Bedrock API token. - Select AWS Bedrock in settings and pick a model. <!-- End of auto-generated description by cubic. --> Co-authored-by: Samrat Jha <samratj@amazon.com> Co-authored-by: Will Chen <willchen90@gmail.com>
This commit is contained in:
@@ -5,6 +5,7 @@ import { createVertex as createGoogleVertex } from "@ai-sdk/google-vertex";
|
||||
import { azure } from "@ai-sdk/azure";
|
||||
import { createOpenRouter } from "@openrouter/ai-sdk-provider";
|
||||
import { createOpenAICompatible } from "@ai-sdk/openai-compatible";
|
||||
import { createAmazonBedrock } from "@ai-sdk/amazon-bedrock";
|
||||
import type {
|
||||
LargeLanguageModel,
|
||||
UserSettings,
|
||||
@@ -342,6 +343,21 @@ function getRegularModelClient(
|
||||
backupModelClients: [],
|
||||
};
|
||||
}
|
||||
case "bedrock": {
|
||||
// AWS Bedrock supports API key authentication using AWS_BEARER_TOKEN_BEDROCK
|
||||
// See: https://sdk.vercel.ai/providers/ai-sdk-providers/amazon-bedrock#api-key-authentication
|
||||
const provider = createAmazonBedrock({
|
||||
apiKey: apiKey,
|
||||
region: getEnvVar("AWS_REGION") || "us-east-1",
|
||||
});
|
||||
return {
|
||||
modelClient: {
|
||||
model: provider(model.name),
|
||||
builtinProviderId: providerId,
|
||||
},
|
||||
backupModelClients: [],
|
||||
};
|
||||
}
|
||||
default: {
|
||||
// Handle custom providers
|
||||
if (providerConfig.type === "custom") {
|
||||
|
||||
Reference in New Issue
Block a user