amazon_product / test_genai_final.py
d-e-e-k-11's picture
Upload folder using huggingface_hub
4416e3b verified
import os
from dotenv import load_dotenv
import google.generativeai as genai
load_dotenv()
api_key = os.getenv("GOOGLE_API_KEY")
if not api_key:
print("Error: No API key found in .env")
else:
try:
genai.configure(api_key=api_key)
# Try a model that was listed
model = genai.GenerativeModel('gemini-flash-latest')
print("Attempting to generate content with gemini-flash-latest...")
response = model.generate_content("Say hello")
print("Success! Response:", response.text)
except Exception as e:
print(f"Failed to call API: {e}")