{"record":{"id":"db5d48767f161ad0","repo":"abi/screenshot-to-code","slug":"gemini-api-key-not-found","errorCode":null,"errorMessage":"Gemini API key not found","messagePattern":"Gemini API key not found","errorType":"exception","errorClass":"Exception","httpStatus":null,"severity":"critical","filePath":"backend/evals/core.py","lineNumber":44,"sourceCode":"    input_mode: str,\n    eval_set: str | None,\n    eval_session_id: str | None,\n    input_file: str | None,\n) -> str:\n    async def send_message(\n        _: str,\n        __: str | None,\n        ___: int,\n        ____: dict[str, Any] | None = None,\n        _____: str | None = None,\n    ) -> None:\n        # Evals do not stream tool/assistant messages to a frontend.\n        return None\n\n    if model in ANTHROPIC_MODELS and not ANTHROPIC_API_KEY:\n        raise Exception(\"Anthropic API key not found\")\n    if model in GEMINI_MODELS and not GEMINI_API_KEY:\n        raise Exception(\"Gemini API key not found\")\n    if model in OPENAI_MODELS and not OPENAI_API_KEY:\n        raise Exception(\"OpenAI API key not found\")\n\n    print(f\"[EVALS] Using agent runner for model: {model.value}\")\n\n    recorder = AgentRunRecorder(\n        generation_id=(\n            f\"gen_{datetime.now().strftime('%Y%m%d_%H%M%S')}_{uuid.uuid4().hex[:8]}\"\n        ),\n        variant_index=0,\n        entry_point=\"eval\",\n        stack=str(stack),\n        input_mode=input_mode,\n        generation_type=\"create\",\n        eval_session=eval_session_id,\n        eval_set=eval_set,\n        input_file=input_file,\n    )","sourceCodeStart":26,"sourceCodeEnd":62,"githubUrl":"https://github.com/abi/screenshot-to-code/blob/d026163f586dfa8c5c10d28c36edd59a9d3b0e88/backend/evals/core.py#L26-L62","documentation":"Exception raised by the eval runner core when model is in GEMINI_MODELS and the module-level GEMINI_API_KEY is empty. Eval runs use Gemini for the evaluated model (and potentially for asset extraction), so the guard fires before the agent runner and recorder are built.","triggerScenarios":"Starting an eval run with a Gemini model while GEMINI_API_KEY is unset in the process running the evals.","commonSituations":"Same key configured for the app but evals run in a separate process/cron without the var; key added to .env after the eval worker started.","solutions":["Set GEMINI_API_KEY in the environment / backend/.env of the process that executes evals and restart it.","Confirm the exact variable name (GEMINI_API_KEY, not GOOGLE_API_KEY).","Evaluate a different model family if no Gemini key is available."],"exampleFix":"# backend/.env\nGEMINI_API_KEY=AIza...","handlingStrategy":"validation","validationCode":"import os\nif model in GEMINI_MODELS and not os.environ.get(\"GEMINI_API_KEY\"):\n    raise SystemExit(\"GEMINI_API_KEY not set; cannot run evals on Gemini models\")","typeGuard":null,"tryCatchPattern":"try:\n    await run_eval(...)\nexcept Exception as e:\n    if \"API key not found\" in str(e):\n        abort_run(\"Configure GEMINI_API_KEY and restart the eval worker\")","preventionTips":["Use the exact env var name GEMINI_API_KEY in eval worker configs.","Add a preflight check listing model->key status before starting an eval session."],"tags":["api-key","gemini","evals","config"],"backgroundTag":null,"analyzedSha":"d026163f586dfa8c5c10d28c36edd59a9d3b0e88","analyzedAt":"2026-08-14T22:02:06.951Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}