video-query/backend/test_api.py
2025-09-18 14:25:24 -05:00

23 lines
No EOL
592 B
Python

import google.generativeai as genai
import os
from dotenv import load_dotenv
# Load environment variables
load_dotenv()
print(f"API Key set: {bool(os.getenv('GOOGLE_API_KEY'))}")
try:
# Configure client with API key
api_key = os.getenv("GOOGLE_API_KEY")
genai.configure(api_key=api_key)
# Test connection
model = genai.GenerativeModel('gemini-1.5-pro')
response = model.generate_content('Test the API connection')
print("API connection test successful!")
print(f"Response: {response.text}")
except Exception as e:
print(f"API error: {e}")