File size: 936 Bytes
1784254
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import os
import google.generativeai as genai
from dotenv import load_dotenv

load_dotenv()

api_key = os.getenv("GEMINI_API_KEY")
if not api_key:
    api_key = os.getenv("GEMINI_API_KEY_1")
if not api_key:
    api_key = os.getenv("GEMINI_API_KEY_2")

if not api_key:
    print("Error: GEMINI_API_KEY (or variants) not found in environment.")
else:
    # Use the google.genai client similar to app.py 
    # But for listing models, the google.generativeai module is often easier/standard
    # Let's try to stick to what works for listing.
    genai.configure(api_key=api_key)
    print(f"Checking models for key ending in ...{api_key[-4:]}")
    
    try:
        print("\nAvailable Models:")
        for m in genai.list_models():
            if 'generateContent' in m.supported_generation_methods:
                print(f"- {m.name}")
    except Exception as e:
        print(f"Error listing models: {e}")