import fs from "fs";

const envContent = fs.readFileSync(".env.local", "utf-8");
const apiKeyMatch = envContent.match(/OPENROUTER_API_KEY=([^\r\n]+)/);
const apiKey = apiKeyMatch ? apiKeyMatch[1].trim() : "";

async function searchModels() {
  const res = await fetch("https://openrouter.ai/api/v1/models", {
    headers: {
      "Authorization": `Bearer ${apiKey}`,
    }
  });

  const data = await res.json();
  const models = data.data || [];
  
  const lunaModels = models.filter(m => m.id.toLowerCase().includes("luna") || m.id.toLowerCase().includes("gpt-5"));
  console.log("Found matches for 'luna' or 'gpt-5':", lunaModels.map(m => ({ id: m.id, name: m.name, pricing: m.pricing })));

  const visionModels = models.filter(m => m.architecture && m.architecture.modality && m.architecture.modality.includes("image->text"));
  console.log(`Total vision models on OpenRouter: ${visionModels.length}`);
}

searchModels().catch(console.error);
