fix(metadata): accept GOOGLE_GEMINI_API_KEY in gemini_session — host metadata extraction was fully broken #255
@@ -14,8 +14,9 @@ sensitive work — decision writing, analysis, halacha extraction — stays on
|
|||||||
``claude_session`` (Daphna's subscription, zero API cost). This is a deliberate
|
``claude_session`` (Daphna's subscription, zero API cost). This is a deliberate
|
||||||
per-task provider choice, not a wholesale move off Claude.
|
per-task provider choice, not a wholesale move off Claude.
|
||||||
|
|
||||||
Key: ``GEMINI_API_KEY`` (host ~/.env; SoT Infisical nautilus:/external-apis/gemini
|
Key: ``GOOGLE_GEMINI_API_KEY`` (the canonical host ~/.env / Infisical name, SoT
|
||||||
as ``GOOGLE_GEMINI_API_KEY``). Model: ``GEMINI_MODEL`` (default gemini-2.5-flash).
|
nautilus:/external-apis/gemini); ``GEMINI_API_KEY`` is also accepted as an alias.
|
||||||
|
Model: ``GEMINI_MODEL`` (default gemini-2.5-flash).
|
||||||
Direct REST via httpx — no extra SDK dependency.
|
Direct REST via httpx — no extra SDK dependency.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
@@ -39,11 +40,19 @@ class GeminiError(RuntimeError):
|
|||||||
|
|
||||||
|
|
||||||
def _api_key() -> str:
|
def _api_key() -> str:
|
||||||
key = os.environ.get("GEMINI_API_KEY", "").strip()
|
# Accept BOTH names: the canonical Infisical / host-~/.env secret is
|
||||||
|
# ``GOOGLE_GEMINI_API_KEY`` (SoT nautilus:/external-apis/gemini), while older
|
||||||
|
# call sites / container envs may export ``GEMINI_API_KEY``. Reading only the
|
||||||
|
# latter silently broke ALL host metadata extraction (the key is present but
|
||||||
|
# under the canonical name). Prefer GEMINI_API_KEY if set, else the SoT name.
|
||||||
|
key = (
|
||||||
|
os.environ.get("GEMINI_API_KEY", "").strip()
|
||||||
|
or os.environ.get("GOOGLE_GEMINI_API_KEY", "").strip()
|
||||||
|
)
|
||||||
if not key:
|
if not key:
|
||||||
raise GeminiError(
|
raise GeminiError(
|
||||||
"GEMINI_API_KEY אינו מוגדר (host ~/.env / Infisical "
|
"GEMINI_API_KEY/GOOGLE_GEMINI_API_KEY אינו מוגדר (host ~/.env / "
|
||||||
"nautilus:/external-apis/gemini)."
|
"Infisical nautilus:/external-apis/gemini)."
|
||||||
)
|
)
|
||||||
return key
|
return key
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user