feat(zai): auto-detect endpoint + default glm-5 (#14786)

* feat(zai): auto-detect endpoint + default glm-5

* test: fix Z.AI default endpoint expectation (#14786)

* test: bump embedded runner beforeAll timeout

* chore: update changelog for Z.AI GLM-5 autodetect (#14786)

* chore: resolve changelog merge conflict with main (#14786)

* chore: append changelog note for #14786 without merge conflict

* chore: sync changelog with main to resolve merge conflict
This commit is contained in:
Peter Steinberger
2026-02-12 19:16:04 +01:00
committed by GitHub
parent 2b5df1dfea
commit 5e7842a41d
15 changed files with 406 additions and 66 deletions

View File

@@ -53,6 +53,7 @@ import {
resolveCustomProviderId,
} from "../../onboard-custom.js";
import { applyOpenAIConfig } from "../../openai-model-default.js";
import { detectZaiEndpoint } from "../../zai-endpoint-detect.js";
import { resolveNonInteractiveApiKey } from "../api-keys.js";
export async function applyNonInteractiveAuthChoice(params: {
@@ -214,8 +215,10 @@ export async function applyNonInteractiveAuthChoice(params: {
mode: "api_key",
});
// Determine endpoint from authChoice or opts
// Determine endpoint from authChoice or detect from the API key.
let endpoint: "global" | "cn" | "coding-global" | "coding-cn" | undefined;
let modelIdOverride: string | undefined;
if (authChoice === "zai-coding-global") {
endpoint = "coding-global";
} else if (authChoice === "zai-coding-cn") {
@@ -225,9 +228,19 @@ export async function applyNonInteractiveAuthChoice(params: {
} else if (authChoice === "zai-cn") {
endpoint = "cn";
} else {
endpoint = "coding-global";
const detected = await detectZaiEndpoint({ apiKey: resolved.key });
if (detected) {
endpoint = detected.endpoint;
modelIdOverride = detected.modelId;
} else {
endpoint = "global";
}
}
return applyZaiConfig(nextConfig, { endpoint });
return applyZaiConfig(nextConfig, {
endpoint,
...(modelIdOverride ? { modelId: modelIdOverride } : {}),
});
}
if (authChoice === "xiaomi-api-key") {