Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions packages/openai-adapters/src/apis/AnthropicUtils.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,14 +93,14 @@ describe("getAnthropicHeaders", () => {
expect(headers["api-key"]).toBeUndefined();
});

it("uses api-key for Azure AI Foundry endpoint", () => {
it("uses x-api-key for Azure AI Foundry endpoint", () => {
const headers = getAnthropicHeaders(
"azure-key",
false,
"https://my-resource.services.ai.azure.com/anthropic",
);
expect(headers["api-key"]).toBe("azure-key");
expect(headers["x-api-key"]).toBeUndefined();
expect(headers["x-api-key"]).toBe("azure-key");
expect(headers["api-key"]).toBeUndefined();
});

it("uses api-key for Azure Cognitive Services endpoint", () => {
Expand Down
5 changes: 4 additions & 1 deletion packages/openai-adapters/src/apis/AnthropicUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,10 @@ export function getAnthropicHeaders(
);
}

const authHeaderName = isAzure ? "api-key" : "x-api-key";
const authHeaderName =
isAzure && apiBase?.toLowerCase().includes("cognitiveservices.azure.com")
? "api-key"
: "x-api-key";

const headers: Record<string, string> = {
"Content-Type": "application/json",
Expand Down
Loading