Spaces:
Sleeping
Sleeping
File size: 525 Bytes
127a3b7 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
import os
from google import genai
def get_genai_client():
"""
Initialize and return a Google GenAI client using an API key from the environment.
"""
api_key = os.getenv("GOOGLE_GENAI_API_KEY")
if not api_key:
raise ValueError("API key not found. Please set the 'GOOGLE_GENAI_API_KEY' environment variable.")
try:
client = genai.Client(api_key=api_key)
return client
except Exception as e:
raise RuntimeError(f"Failed to initialize Google GenAI client: {e}")
|