Spaces:
Running
Running
| """Shared google-genai client factory (fresh client per call).""" | |
| from __future__ import annotations | |
| from google import genai | |
| from config import get_api_key | |
| def get_genai_client() -> genai.Client: | |
| api_key = get_api_key() | |
| if not api_key: | |
| raise RuntimeError("GOOGLE_API_KEY is missing") | |
| # Always create a new client — reused/closed clients cause | |
| # "Cannot send a request, as the client has been closed." | |
| return genai.Client(api_key=api_key) | |