MHRDYN7's picture
Deploy Anti-Hallucination Chat to personal Space
f3793b5 verified
Raw
History Blame Contribute Delete
474 Bytes
"""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)