SPB Git
1.2 KB · 25 lines typescript
1import OpenAI from "openai";2import Anthropic from "@anthropic-ai/sdk";3import fs from "node:fs";45const openai = new OpenAI();6const anthropic = new Anthropic();78const out: any = { generatedAt: new Date().toISOString(), openai: [], anthropic: [], errors: {} };910try {11  const page = await openai.models.list();12  for await (const m of page) out.openai.push({ id: m.id, owned_by: m.owned_by, created: m.created });13  out.openai.sort((a: any, b: any) => a.id.localeCompare(b.id));14} catch (e: any) { out.errors.openai = `${e.status ?? ""} ${e.message}`; }1516try {17  for await (const m of anthropic.models.list()) out.anthropic.push(m);18  out.anthropic.sort((a: any, b: any) => a.id.localeCompare(b.id));19} catch (e: any) { out.errors.anthropic = `${e.status ?? ""} ${e.message}`; }2021fs.writeFileSync("benchmarks/model-discovery.json", JSON.stringify(out, null, 2));22console.log("openai models:", out.openai.length, "anthropic models:", out.anthropic.length, "errors:", JSON.stringify(out.errors));23console.log("OPENAI:", out.openai.map((m: any) => m.id).join(" "));24console.log("ANTHROPIC:", out.anthropic.map((m: any) => `${m.id}[${m.max_input_tokens ?? "?"}/${m.max_tokens ?? "?"}]`).join(" "));25
Files · main
Menu

Theme