Skip to content

Commit c517162

Browse files
committed
fix(azure): narrow Foundry Responses client detection
1 parent 1240de7 commit c517162

2 files changed

Lines changed: 24 additions & 0 deletions

File tree

src/llm/providers/azure-openai-responses.test.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,11 @@ describe("azure-openai-responses", () => {
4545
"https://project.services.ai.azure.com/openai/v1",
4646
),
4747
).toBe(true);
48+
expect(
49+
testing.isOpenAICompatibleAzureResponsesBaseUrl(
50+
"https://eastus.api.cognitive.microsoft.com/openai/v1",
51+
),
52+
).toBe(true);
4853
});
4954

5055
it("does not treat non-v1 custom endpoints as OpenAI-compatible Responses bases", () => {
@@ -54,4 +59,15 @@ describe("azure-openai-responses", () => {
5459
),
5560
).toBe(false);
5661
});
62+
63+
it("keeps private or APIM Azure OpenAI-compatible paths on the AzureOpenAI client path", () => {
64+
expect(testing.isOpenAICompatibleAzureResponsesBaseUrl("https://aoai.internal/openai/v1")).toBe(
65+
false,
66+
);
67+
expect(
68+
testing.isOpenAICompatibleAzureResponsesBaseUrl(
69+
"https://gateway.example.com/proxy/openai/v1",
70+
),
71+
).toBe(false);
72+
});
5773
});

src/shared/azure-openai-responses-client-compat.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,14 @@ export function isOpenAICompatibleAzureResponsesBaseUrl(baseUrl: string): boolea
1616
return false;
1717
}
1818

19+
const hostname = url.hostname.toLowerCase();
20+
const isFoundryHost =
21+
hostname.endsWith(".services.ai.azure.com") ||
22+
hostname.endsWith(".api.cognitive.microsoft.com");
23+
if (!isFoundryHost) {
24+
return false;
25+
}
26+
1927
const normalizedPath = url.pathname.replace(/\/+$/, "");
2028
return normalizedPath === "/openai/v1" || normalizedPath.endsWith("/openai/v1");
2129
}

0 commit comments

Comments
 (0)