-
Notifications
You must be signed in to change notification settings - Fork 218
feat(cli): add AWS Bedrock as a supported provider #1015
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -4,6 +4,7 @@ import type { SupportedProvider } from "@/types/index.js" | |||||
|
|
||||||
| const envVarMap: Record<SupportedProvider, string> = { | ||||||
| anthropic: "ANTHROPIC_API_KEY", | ||||||
| bedrock: "AWS_BEDROCK_API_KEY", | ||||||
| "openai-native": "OPENAI_API_KEY", | ||||||
| gemini: "GOOGLE_API_KEY", | ||||||
| openrouter: "OPENROUTER_API_KEY", | ||||||
|
|
@@ -31,6 +32,36 @@ export function getProviderSettings( | |||||
| if (apiKey) config.apiKey = apiKey | ||||||
| if (model) config.apiModelId = model | ||||||
| break | ||||||
| case "bedrock": | ||||||
| config.awsRegion = process.env.AWS_REGION || process.env.AWS_DEFAULT_REGION || "us-east-1" | ||||||
| if (model) { | ||||||
| config.apiModelId = model | ||||||
| // Auto-enable cross-region inference when model ID has a regional prefix | ||||||
| // (e.g. "us.", "eu.", "apac.") — these are cross-region inference profiles | ||||||
| // that require awsUseCrossRegionInference to be set. | ||||||
| if (/^(us|eu|apac)\./.test(model)) { | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This regex only covers Would it make sense to derive this from the existing mapping rather than maintaining a parallel regex?
Suggested change
|
||||||
| config.awsUseCrossRegionInference = true | ||||||
| } | ||||||
| } | ||||||
|
|
||||||
| if (apiKey) { | ||||||
| // Bearer token / API key mode (LiteLLM proxy, Bedrock gateway) | ||||||
| config.awsUseApiKey = true | ||||||
| config.awsApiKey = apiKey | ||||||
| } else if (process.env.AWS_PROFILE) { | ||||||
| // Profile-based auth | ||||||
| config.awsUseProfile = true | ||||||
| config.awsProfile = process.env.AWS_PROFILE | ||||||
| } else if (process.env.AWS_ACCESS_KEY_ID && process.env.AWS_SECRET_ACCESS_KEY) { | ||||||
| // Direct credentials from env | ||||||
| config.awsAccessKey = process.env.AWS_ACCESS_KEY_ID | ||||||
| config.awsSecretKey = process.env.AWS_SECRET_ACCESS_KEY | ||||||
| if (process.env.AWS_SESSION_TOKEN) { | ||||||
| config.awsSessionToken = process.env.AWS_SESSION_TOKEN | ||||||
| } | ||||||
| } | ||||||
| // else: fall through to default credential chain (SDK handles IMDS, ECS task role, etc.) | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If a user switches auth modes between CLI runs — e.g. from Would explicitly clearing the non-winning flags fix this? |
||||||
| break | ||||||
| case "openai-native": | ||||||
| if (apiKey) config.openAiNativeApiKey = apiKey | ||||||
| if (model) config.apiModelId = model | ||||||
|
|
||||||
Uh oh!
There was an error while loading. Please reload this page.