fix(foundry): keep API-key Claude auth

This commit is contained in:
Vincent Koc
2026-06-10 14:24:42 +09:00
parent b66f0b6ca3
commit 378ae44aad
3 changed files with 38 additions and 1 deletions

View File

@@ -38,6 +38,18 @@ Choose your preferred auth method and follow the setup steps.
export AWS_BEARER_TOKEN_BEDROCK="..."
```
</Step>
<Step title="Opt in to provider data sharing for Claude Fable 5">
Claude Fable 5 and Claude Mythos-class Bedrock models require the Bedrock Data Retention API mode `provider_data_share` before invocation. This opt-in allows Bedrock to share prompts and completions with Anthropic and retain them for up to 30 days for trust and safety review.
```bash
curl -X PUT https://bedrock-mantle.us-east-1.api.aws/v1/data_retention \
-H "x-api-key: $BEDROCK_API_KEY" \
-H "Content-Type: application/json" \
-d '{ "mode": "provider_data_share" }'
```
Use another Bedrock model in the config if you cannot accept that retention mode.
</Step>
<Step title="Add a Bedrock provider and model to your config">
No `apiKey` is required. Configure the provider with `auth: "aws-sdk"`:

View File

@@ -87,6 +87,7 @@ describe("Anthropic provider", () => {
const model = makeAnthropicModel({
provider: "microsoft-foundry",
baseUrl: "https://example.services.ai.azure.com/anthropic",
authHeader: true,
});
const context = {
messages: [{ role: "user", content: "hello", timestamp: 1 }],
@@ -108,6 +109,30 @@ describe("Anthropic provider", () => {
expect(config.defaultHeaders?.["x-api-key"]).toBeUndefined();
});
it("keeps Microsoft Foundry API-key profiles on Anthropic API key auth", async () => {
const model = makeAnthropicModel({
provider: "microsoft-foundry",
baseUrl: "https://example.services.ai.azure.com/anthropic",
authHeader: false,
});
const context = {
messages: [{ role: "user", content: "hello", timestamp: 1 }],
} satisfies Context;
streamAnthropic(model, context, {
apiKey: "foundry-resource-key",
});
await vi.waitFor(() => expect(anthropicMockState.configs).toHaveLength(1));
const config = anthropicMockState.configs[0] as {
apiKey?: string | null;
authToken?: string | null;
};
expect(config.apiKey).toBe("foundry-resource-key");
expect(config.authToken).toBeNull();
});
it("preserves provider-signed Anthropic thinking and drops reasoning_content placeholders", async () => {
const highSurrogate = String.fromCharCode(0xd83d);
const signedThinking = `keep${highSurrogate}signed`;

View File

@@ -945,7 +945,7 @@ function createClient(
return { client, isOAuthToken: false };
}
if (model.provider === "microsoft-foundry") {
if (model.provider === "microsoft-foundry" && model.authHeader === true) {
const client = new Anthropic({
apiKey: null,
authToken: apiKey,