fix: support Bedrock API key login

This commit is contained in:
Armin Ronacher
2026-07-10 19:34:11 +02:00
parent 91585d9a38
commit 3ea064ea2a
10 changed files with 72 additions and 36 deletions
@@ -152,7 +152,10 @@ export const stream: StreamFunction<"bedrock-converse-stream", BedrockOptions> =
// Resolve bearer token for Bedrock API key auth.
const skipAuth = getProviderEnvValue("AWS_BEDROCK_SKIP_AUTH", options.env) === "1";
const bearerToken =
options.bearerToken || getProviderEnvValue("AWS_BEARER_TOKEN_BEDROCK", options.env) || undefined;
options.bearerToken ||
options.apiKey ||
getProviderEnvValue("AWS_BEARER_TOKEN_BEDROCK", options.env) ||
undefined;
const useBearerToken = bearerToken !== undefined && !skipAuth;
// in Node.js/Bun environment only
+5 -1
View File
@@ -9,7 +9,11 @@ import { AMAZON_BEDROCK_MODELS } from "./amazon-bedrock.models.ts";
* configured. A stored credential key is surfaced as the bearer token.
*/
const bedrockAuth: ApiKeyAuth = {
name: "AWS credentials",
name: "Bedrock API key or AWS credentials",
login: async (callbacks) => ({
type: "api_key",
key: await callbacks.prompt({ type: "secret", message: "Enter Bedrock API key" }),
}),
resolve: async ({ ctx, credential }) => {
if (credential?.key) return { auth: { apiKey: credential.key }, source: "stored credential" };
if (await ctx.env("AWS_BEARER_TOKEN_BEDROCK")) return { auth: {}, source: "AWS_BEARER_TOKEN_BEDROCK" };