Sending x-api-key instead of api-key as header for azure hosted anthropic service (#11517)
* Fix for sending x-api-key instead of api-key as header for newer azure hosted anthropic service * Update packages/openai-adapters/src/apis/AnthropicUtils.ts Co-authored-by: cubic-dev-ai[bot] <191113872+cubic-dev-ai[bot]@users.noreply.github.com> * fix: update test to expect x-api-key for Azure AI Foundry endpoints Azure AI Foundry (services.ai.azure.com) uses x-api-key, while only cognitiveservices.azure.com uses api-key. Update the test to match. --------- Co-authored-by: cubic-dev-ai[bot] <191113872+cubic-dev-ai[bot]@users.noreply.github.com> Co-authored-by: Dallin Romney <dallinromney@gmail.com>
This commit is contained in:
parent
6e0045e204
commit
fd559bbc8e
2 changed files with 7 additions and 4 deletions
|
|
@ -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", () => {
|
||||
|
|
|
|||
|
|
@ -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",
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue