fix: recognize api.grok.x.ai as xAI-native endpoint

Fixes #61377

The provider attribution code only recognized api.x.ai as the xAI-native
endpoint. Some users have api.grok.x.ai configured (or it appears in
certain DNS/config scenarios) which would not resolve as xAI-native,
causing web_search tool failures.

This change adds api.grok.x.ai as an alias for xAI-native endpoint
classification alongside api.x.ai.
This commit is contained in:
jjjojoj
2026-04-06 08:41:18 +08:00
committed by Peter Steinberger
parent 6067f2d9ad
commit b35b176837
2 changed files with 5 additions and 1 deletions

View File

@@ -232,6 +232,10 @@ describe("provider attribution", () => {
endpointClass: "xai-native",
hostname: "api.x.ai",
});
expect(resolveProviderEndpoint("https://api.grok.x.ai/v1")).toMatchObject({
endpointClass: "xai-native",
hostname: "api.grok.x.ai",
});
expect(resolveProviderEndpoint("https://api.z.ai/api/coding/paas/v4")).toMatchObject({
endpointClass: "zai-native",
hostname: "api.z.ai",

View File

@@ -238,7 +238,7 @@ export function resolveProviderEndpoint(
if (host === "openrouter.ai" || host.endsWith(".openrouter.ai")) {
return { endpointClass: "openrouter", hostname: host };
}
if (host === "api.x.ai") {
if (host === "api.x.ai" || host === "api.grok.x.ai") {
return { endpointClass: "xai-native", hostname: host };
}
if (host === "api.z.ai") {