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
@@ -181,4 +181,13 @@ describe("bedrock endpoint resolution", () => {
expect(config.region).toBe("us-gov-west-1");
});
it("uses the generic API key option as a Bedrock bearer token", async () => {
const model = getModel("amazon-bedrock", "us.anthropic.claude-opus-4-8");
const config = await captureClientConfig(model, { apiKey: "bedrock-api-key" });
expect(config.token).toEqual({ token: "bedrock-api-key" });
expect(config.authSchemePreference).toEqual(["httpBearerAuth"]);
});
});
+13
View File
@@ -54,6 +54,19 @@ describe("builtin providers", () => {
expect(result?.source).toBe("ANTHROPIC_OAUTH_TOKEN");
});
it("prompts for and stores a Bedrock API key", async () => {
const provider = amazonBedrockProvider();
const credential = await provider.auth.apiKey?.login?.({
prompt: async (prompt) => {
expect(prompt).toEqual({ type: "secret", message: "Enter Bedrock API key" });
return "bedrock-api-key";
},
notify: () => {},
});
expect(credential).toEqual({ type: "api_key", key: "bedrock-api-key" });
});
it("reports bedrock as configured from ambient AWS credentials without an api key", async () => {
const models = createModels({ authContext: fakeAuthContext({ AWS_PROFILE: "dev" }) });
models.setProvider(amazonBedrockProvider());