Skip to content

Commit 3516f99

Browse files
lgarceau768claude
andcommitted
fix: let IAM credentials take precedence over stored Bedrock API key
When a user has configured AWS IAM credentials (access keys or a profile) for Bedrock, a stored API key in auth.json would still be written into AWS_BEARER_TOKEN_BEDROCK and forced through bearer-token auth by @ai-sdk/amazon-bedrock, overriding the credential chain entirely and failing with "Please make sure your API Key is valid" on every request. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent c99a0a2 commit 3516f99

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

packages/opencode/src/provider/provider.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,8 @@ function custom(dep: CustomDep): Record<string, CustomLoader> {
262262
const awsBearerToken = iife(() => {
263263
const envToken = process.env.AWS_BEARER_TOKEN_BEDROCK
264264
if (envToken) return envToken
265-
if (auth?.type === "api") {
265+
// Only treat stored auth key as a bearer token when no IAM credentials exist.
266+
if (auth?.type === "api" && !awsAccessKeyId && !profile) {
266267
process.env.AWS_BEARER_TOKEN_BEDROCK = auth.key
267268
return auth.key
268269
}

0 commit comments

Comments
 (0)