import asyncio
import os
import httpx
import json
from dotenv import load_dotenv

load_dotenv()
API_KEY = os.getenv("GOOGLE_API_KEY")

async def list_models():
    url = f"https://generativelanguage.googleapis.com/v1beta/models?key={API_KEY}"
    async with httpx.AsyncClient() as client:
        response = await client.get(url)
        if response.status_code == 200:
            data = response.json()
            models = data.get("models", [])
            print(f"Found {len(models)} models:")
            for m in models:
                name = m.get("name")
                display = m.get("displayName", "No Display Name")
                print(f" - {name} ({display})")
        else:
            print(f"Error: {response.status_code} - {response.text}")

if __name__ == "__main__":
    asyncio.run(list_models())
