Vertical.ai / backend /scripts /verify_gemini_model.py
Abhisingh-18's picture
Mirror of github.com/Abhisingh18/Vertical.ai
1f7ead8 verified
Raw
History Blame Contribute Delete
1.39 kB
import google.generativeai as genai
import sys
import os
# Add project root to path
sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), '..', '..')))
from backend.app.config import config
def find_working_model():
key = config.GEMINI_API_KEY
if not key:
print("ERROR: GEMINI_API_KEY is missing.")
return
genai.configure(api_key=key)
print("Searching for a working model...")
try:
# Iterate over all available models
for m in genai.list_models():
if 'generateContent' in m.supported_generation_methods:
print(f"Trying candidate: {m.name}...")
try:
model = genai.GenerativeModel(m.name)
# Simple test
response = model.generate_content("Test")
print(f"SUCCESS! WORKING MODEL FOUND: {m.name}")
with open("working_model.txt", "w") as f:
f.write(m.name)
print(f"Response: {response.text}")
return # Stop at first success
except Exception as e:
pass
# print(f" > Failed: {e}")
except Exception as e:
print(f"Error listing models: {e}")
if __name__ == "__main__":
find_working_model()