grading-agent / gapi_client.py
Hammad712's picture
Create gapi_client.py
127a3b7 verified
raw
history blame contribute delete
525 Bytes
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}")