import os
from pathlib import Path
import google.generativeai as genai

BASE_DIR = Path(__file__).parent.parent
GEMINI_API_KEY = os.environ.get("GEMINI_API_KEY", "")
if not GEMINI_API_KEY:
    try:
        with open(BASE_DIR / "config" / "secrets.env", "r") as f:
            for line in f:
                if line.startswith("GEMINI_API_KEY="):
                    GEMINI_API_KEY = line.split("=")[1].strip().strip('"\'')
    except Exception:
        pass

genai.configure(api_key=GEMINI_API_KEY)

for m in genai.list_models():
    if 'generateContent' in m.supported_generation_methods:
        print(m.name)
