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
701 B
Raw Blame
import type { Db } from '../types.js';

function hasColumn(db: Db, table: string, column: string): boolean {
  const columns = db.prepare(`PRAGMA table_info(${table})`).all() as { name: string }[];
  return columns.some((candidate) => candidate.name === column);
}

/** Persist the most recent failed health-probe reason for local diagnostics. */
export function up(db: Db): void {
  if (!hasColumn(db, 'api_keys', 'last_health_error')) {
    db.prepare('ALTER TABLE api_keys ADD COLUMN last_health_error TEXT').run();
  }
}

export function down(db: Db): void {
  if (hasColumn(db, 'api_keys', 'last_health_error')) {
    db.prepare('ALTER TABLE api_keys DROP COLUMN last_health_error').run();
  }
}