mirror of
https://github.com/Nezumi-2711/9router.git
synced 2026-09-22 13:38:31 +00:00
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:
co-authored by
ant-joshua
parent
7aa7a11599
commit
cce8a50cac
@@ -608,6 +608,23 @@ async function testApiKeyConnection(connection, effectiveProxy = null) {
|
|||||||
const valid = !!(data && data.user);
|
const valid = !!(data && data.user);
|
||||||
return { valid, error: valid ? null : "Session expired — re-paste cookie" };
|
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:
|
default:
|
||||||
return { valid: false, error: "Provider test not supported" };
|
return { valid: false, error: "Provider test not supported" };
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user