import OpenAI from "openai"; import Anthropic from "@anthropic-ai/sdk"; import fs from "node:fs"; const openai = new OpenAI(); const anthropic = new Anthropic(); const out: any = { generatedAt: new Date().toISOString(), openai: [], anthropic: [], errors: {} }; try { const page = await openai.models.list(); for await (const m of page) out.openai.push({ id: m.id, owned_by: m.owned_by, created: m.created }); out.openai.sort((a: any, b: any) => a.id.localeCompare(b.id)); } catch (e: any) { out.errors.openai = `${e.status ?? ""} ${e.message}`; } try { for await (const m of anthropic.models.list()) out.anthropic.push(m); out.anthropic.sort((a: any, b: any) => a.id.localeCompare(b.id)); } catch (e: any) { out.errors.anthropic = `${e.status ?? ""} ${e.message}`; } fs.writeFileSync("benchmarks/model-discovery.json", JSON.stringify(out, null, 2)); console.log("openai models:", out.openai.length, "anthropic models:", out.anthropic.length, "errors:", JSON.stringify(out.errors)); console.log("OPENAI:", out.openai.map((m: any) => m.id).join(" ")); console.log("ANTHROPIC:", out.anthropic.map((m: any) => `${m.id}[${m.max_input_tokens ?? "?"}/${m.max_tokens ?? "?"}]`).join(" "));