fix: add opencode-go and xiaomi-tokenplan cases to connection test route (#1576)

Co-authored-by: ant-joshua <ant-joshua@users.noreply.github.com>
This commit is contained in:
Antonius Joshua
2026-05-31 15:03:20 +07:00
committed by GitHub
parent 7aa7a11599
commit cce8a50cac

View File

@@ -608,6 +608,23 @@ async function testApiKeyConnection(connection, effectiveProxy = null) {
const valid = !!(data && data.user);
return { valid, error: valid ? null : "Session expired — re-paste cookie" };
}
case "opencode-go": {
const res = await fetchWithConnectionProxy("https://opencode.ai/zen/go/v1/chat/completions", {
method: "POST",
headers: { "Content-Type": "application/json", Authorization: `Bearer ${connection.apiKey}` },
body: JSON.stringify({ model: getDefaultModel("opencode-go"), messages: [{ role: "user", content: "ping" }], max_tokens: 1, stream: false }),
}, effectiveProxy);
const valid = res.status !== 401 && res.status !== 403;
return { valid, error: valid ? null : "Invalid API key" };
}
case "xiaomi-mimo":
case "xiaomi-tokenplan": {
const baseUrls = { "xiaomi-mimo": "https://api.xiaomimimo.com/v1", "xiaomi-tokenplan": "https://token-plan-sgp.xiaomimimo.com/v1" };
const res = await fetchWithConnectionProxy(`${baseUrls[connection.provider]}/models`, {
headers: { Authorization: `Bearer ${connection.apiKey}` },
}, effectiveProxy);
return { valid: res.ok, error: res.ok ? null : "Invalid API key" };
}
default:
return { valid: false, error: "Provider test not supported" };
}