Spaces:
Sleeping
Sleeping
File size: 1,592 Bytes
f227564 3c90289 f227564 e0dea15 f227564 e0dea15 f227564 3c90289 f227564 e0dea15 f227564 e0dea15 f227564 3c90289 f227564 e0dea15 f227564 e0dea15 f227564 3c90289 f227564 e0dea15 |
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 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
<<<<<<< HEAD
=======
>>>>>>> 3c90289feb86aa984187265790919d85c490402a
import os
import sys
from dotenv import load_dotenv
import certifi
<<<<<<< HEAD
# Load environment variables
load_dotenv()
# CRITICAL: Fix for SSL checks on Windows
=======
# Load env var
load_dotenv()
# Fix for SSL checks
>>>>>>> 3c90289feb86aa984187265790919d85c490402a
os.environ['SSL_CERT_FILE'] = certifi.where()
try:
from google import genai
except ImportError:
print("β google-genai library not found. Please install with: pip install google-genai")
sys.exit(1)
api_key = os.getenv("GOOGLE_API_KEY")
if not api_key:
print("β GOOGLE_API_KEY not found in environment.")
sys.exit(1)
<<<<<<< HEAD
print(f"π Initializing Client...")
=======
print(f"π Initializing Client with Key: {api_key[:10]}...")
>>>>>>> 3c90289feb86aa984187265790919d85c490402a
client = genai.Client(api_key=api_key)
try:
print("π Sending simple request (Model: gemini-2.0-flash)...")
<<<<<<< HEAD
response = client.models.generate_content(
model="gemini-2.5-flash",
contents="How does AI work? (One sentence answer)"
=======
# Using gemini-2.0-flash as consistent with project config
response = client.models.generate_content(
model="gemini-2.0-flash",
contents="How does AI work? Verify you are functional in 1 short sentence."
>>>>>>> 3c90289feb86aa984187265790919d85c490402a
)
print("\nπ SUCCESS! API Response:")
print("-" * 30)
print(response.text)
print("-" * 30)
except Exception as e:
print(f"\nβ API Call Failed: {e}")
|