Spaces:
Sleeping
Sleeping
| 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}") | |