import httpx
import asyncio
import os
import sys

# Add current directory to path to find app module if needed
sys.path.append(os.getcwd())

try:
    from app.config import settings
    api_key = settings.google_api_key
except ImportError:
    # Try reading .env manually if app config fails
    print("Could not import settings, checking env...")
    from dotenv import load_dotenv
    load_dotenv()
    api_key = os.getenv("GOOGLE_API_KEY")

if not api_key:
    print("No API Key found")
    sys.exit(1)

async def check_models():
    url = f"https://generativelanguage.googleapis.com/v1beta/models?key={api_key}"
    async with httpx.AsyncClient() as client:
        resp = await client.get(url)
        if resp.status_code != 200:
            print(f"Error: {resp.status_code} {resp.text}")
            return
            
        data = resp.json()
        print(f"Found {len(data.get('models', []))} models.")
        for m in data.get('models', []):
            if 'veo' in m['name'].lower() or 'video' in m['name'].lower():
                print(f"Model: {m['name']}")
                print(f" - Methods: {m.get('supportedGenerationMethods')}")

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