Skip to content

7.4 billion tokens per month. 34 free LLM providers. 635 free model endpoints. All behind one /v1 endpoint, plus any custom OpenAI-compatible endpoint. Smart routing, automatic failover, encrypted keys. Personal experimentation only.

TypeScript

feat(catalog): migrateModelsV7 — probe-verified OR :free delta + Z.ai (#15)

Tashfeen4c879e50a137
diff --git a/server/src/db/index.ts b/server/src/db/index.ts
index 4d4687c1..582cf8dd 100644
--- a/server/src/db/index.ts
+++ b/server/src/db/index.ts
@@ -41,6 +41,7 @@ export function initDb(dbPath?: string): Database.Database {
migrateModelsV4(db);
migrateModelsV5(db);
migrateModelsV6(db);
+ migrateModelsV7(db);
ensureUnifiedKey(db);
console.log(`Database initialized at ${resolvedPath}`);
@@ -661,6 +662,67 @@ function migrateModelsV6(db: Database.Database) {
apply();
}
+/**
+ * V7 (April 2026): live-probed delta against OpenRouter's free pool + Z.ai.
+ * - Removes inclusionai/ling-2.6-flash:free (transitioned to paid, 404 on chat).
+ * - Adds 8 new :free routes confirmed via /v1/models + chat-completion probe.
+ * - Adds zhipu/glm-4.7-flash (probe: 429 "overloaded" — free-pool throttle, not
+ * "insufficient balance" which paid models return). Same baseUrl works for both
+ * api.z.ai and open.bigmodel.cn keys.
+ * HF and NVIDIA left as-is: HF still serves chat with current key; NVIDIA already disabled.
+ */
+function migrateModelsV7(db: Database.Database) {
+ const deleteModel = db.prepare(`DELETE FROM models WHERE platform = ? AND model_id = ?`);
+ const deleteFallback = db.prepare(`
+ DELETE FROM fallback_config WHERE model_db_id IN (
+ SELECT id FROM models WHERE platform = ? AND model_id = ?
+ )
+ `);
+ const removals: Array<[string, string]> = [
+ ['openrouter', 'inclusionai/ling-2.6-flash:free'],
+ ];
+ const applyRemovals = db.transaction(() => {
+ for (const [p, m] of removals) {
+ deleteFallback.run(p, m);
+ deleteModel.run(p, m);
+ }
+ });
+ applyRemovals();
+
+ const insert = db.prepare(`
+ INSERT OR IGNORE INTO models (platform, model_id, display_name, intelligence_rank, speed_rank, size_label, rpm_limit, rpd_limit, tpm_limit, tpd_limit, monthly_token_budget, context_window)
+ VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
+ `);
+ // OpenRouter :free quotas: 20 RPM / 50 RPD without credits, 1000 RPD with $10 lifetime topup.
+ // Catalog convention is rpd=200 (matches existing rows).
+ const additions: Array<[string, string, string, number, number, string, number | null, number | null, number | null, number | null, string, number | null]> = [
+ ['openrouter', 'inclusionai/ling-2.6-1t:free', 'Ling 2.6 1T (free)', 4, 9, 'Frontier', 20, 200, null, null, '~6M', 262144],
+ ['openrouter', 'tencent/hy3-preview:free', 'Tencent HY3 Preview (free)', 7, 9, 'Frontier', 20, 200, null, null, '~6M', 262144],
+ ['openrouter', 'poolside/laguna-m.1:free', 'Poolside Laguna M.1 (free)', 13, 9, 'Large', 20, 200, null, null, '~6M', 131072],
+ ['openrouter', 'google/gemma-4-26b-a4b-it:free', 'Gemma 4 26B-A4B (free)', 22, 9, 'Medium', 20, 200, null, null, '~6M', 262144],
+ ['openrouter', 'nvidia/nemotron-3-nano-omni-30b-a3b-reasoning:free', 'Nemotron 3 Nano 30B Reasoning (free)', 23, 9, 'Medium', 20, 200, null, null, '~6M', 262144],
+ ['openrouter', 'poolside/laguna-xs.2:free', 'Poolside Laguna XS.2 (free)', 26, 10, 'Medium', 20, 200, null, null, '~6M', 131072],
+ ['openrouter', 'nvidia/nemotron-nano-9b-v2:free', 'Nemotron Nano 9B v2 (free)', 28, 10, 'Medium', 20, 200, null, null, '~6M', 128000],
+ ['openrouter', 'liquid/lfm-2.5-1.2b-thinking:free', 'Liquid LFM 2.5 1.2B Thinking (free)', 30, 10, 'Small', 20, 200, null, null, '~6M', 32768],
+ // Zhipu (Z.ai) — free pool. glm-4.7-flash quotas unpublished; mirror glm-4.5-flash row shape.
+ ['zhipu', 'glm-4.7-flash', 'GLM-4.7 Flash', 18, 4, 'Large', null, null, null, 1000000, '~30M', 131072],
+ ];
+ const apply = db.transaction(() => {
+ for (const a of additions) insert.run(...a);
+ const missing = db.prepare(`
+ SELECT m.id FROM models m
+ LEFT JOIN fallback_config f ON m.id = f.model_db_id
+ WHERE f.id IS NULL ORDER BY m.intelligence_rank ASC
+ `).all() as { id: number }[];
+ if (missing.length > 0) {
+ const maxPriority = (db.prepare('SELECT COALESCE(MAX(priority), 0) AS mx FROM fallback_config').get() as { mx: number }).mx;
+ const addFb = db.prepare('INSERT INTO fallback_config (model_db_id, priority, enabled) VALUES (?, ?, 1)');
+ for (let i = 0; i < missing.length; i++) addFb.run(missing[i].id, maxPriority + i + 1);
+ }
+ });
+ apply();
+}
+
function ensureUnifiedKey(db: Database.Database) {
const existing = db.prepare("SELECT value FROM settings WHERE key = 'unified_api_key'").get() as { value: string } | undefined;
if (!existing) {