-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcheck_model.py
More file actions
30 lines (24 loc) · 998 Bytes
/
check_model.py
File metadata and controls
30 lines (24 loc) · 998 Bytes
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
30
# This is the file: check_models.py
import google.generativeai as genai
import os
from dotenv import load_dotenv
load_dotenv()
# --- Load API key from .env ---
API_KEY = os.getenv("API_KEY")
genai.configure(api_key=API_KEY)
print("Attempting to connect and list available models...")
try:
# This loop asks Google "What models can I use?"
found_model = False
for m in genai.list_models():
# We are looking for models that can "generateContent"
if 'generateContent' in m.supported_generation_methods:
print(f"Found usable model: {m.name}")
found_model = True
if not found_model:
print("\n--- No usable models found ---")
print("This might mean your API key is restricted or billing is not enabled for your project.")
except Exception as e:
print("\n--- A critical error occurred ---")
print(f"Error details: {e}")
print("\nThis usually means your API Key is invalid or the API is not enabled in your project.")