From cce8a50cac501d97c49e563d2a37c3d6ec4da991 Mon Sep 17 00:00:00 2001 From: Antonius Joshua Date: Sun, 31 May 2026 15:03:20 +0700 Subject: [PATCH] fix: add opencode-go and xiaomi-tokenplan cases to connection test route (#1576) Co-authored-by: ant-joshua --- src/app/api/providers/[id]/test/testUtils.js | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/app/api/providers/[id]/test/testUtils.js b/src/app/api/providers/[id]/test/testUtils.js index 364a1236..6d657ecd 100644 --- a/src/app/api/providers/[id]/test/testUtils.js +++ b/src/app/api/providers/[id]/test/testUtils.js @@ -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" }; }