{"record":{"id":"9b07904130b61da5","repo":"abi/screenshot-to-code","slug":"missing-gemini-api-key","errorCode":null,"errorMessage":"Missing GEMINI_API_KEY","messagePattern":"Missing GEMINI_API_KEY","errorType":"exception","errorClass":"SystemExit","httpStatus":null,"severity":"error","filePath":"backend/evals/asset_extraction_benchmark.py","lineNumber":853,"sourceCode":"        \"--iou-threshold\",\n        type=float,\n        default=DEFAULT_IOU_THRESHOLD,\n    )\n    return parser.parse_args()\n\n\nasync def main() -> None:\n    load_dotenv(Path(\".env\"))\n    args = parse_args()\n    if not args.live:\n        raise SystemExit(\n            \"Live API calls are disabled by default. Re-run with --live to opt in.\"\n        )\n    if not 0 <= args.iou_threshold <= 1:\n        raise SystemExit(\"--iou-threshold must be between 0 and 1\")\n    api_key = os.environ.get(\"GEMINI_API_KEY\")\n    if not api_key:\n        raise SystemExit(\"Missing GEMINI_API_KEY\")\n    output_dir = args.output_dir or (\n        DEFAULT_OUTPUT_ROOT / time.strftime(\"%Y%m%d_%H%M%S\")\n    )\n    await run_benchmark(\n        api_key=api_key,\n        output_dir=output_dir,\n        iou_threshold=args.iou_threshold,\n    )\n\n\nif __name__ == \"__main__\":\n    asyncio.run(main())\n","sourceCodeStart":835,"sourceCodeEnd":866,"githubUrl":"https://github.com/abi/screenshot-to-code/blob/d026163f586dfa8c5c10d28c36edd59a9d3b0e88/backend/evals/asset_extraction_benchmark.py#L835-L866","documentation":"SystemExit raised when GEMINI_API_KEY is absent from the environment after load_dotenv(Path('.env')). The benchmark calls Gemini directly (run_benchmark(api_key=...)), so unlike the agent factory there is no alternative provider; the key is mandatory before any work starts.","triggerScenarios":"Running the benchmark with --live but without GEMINI_API_KEY exported or present in backend/.env in the current working directory (load_dotenv uses the relative path '.env').","commonSituations":"Running the script from a directory other than backend/ so the relative .env is not found, or only having OpenAI/Anthropic keys configured.","solutions":["Run the script from the directory containing .env (typically backend/), or export GEMINI_API_KEY in the shell.","Add GEMINI_API_KEY to backend/.env if missing."],"exampleFix":"# before (run from repo root)\npython evals/asset_extraction_benchmark.py --live\n\n# after\nexport GEMINI_API_KEY=AIza...\npython evals/asset_extraction_benchmark.py --live","handlingStrategy":"validation","validationCode":"api_key = os.environ.get(\"GEMINI_API_KEY\")\nif not api_key:\n    sys.exit(\"Missing GEMINI_API_KEY — export it or add to backend/.env\")","typeGuard":null,"tryCatchPattern":null,"preventionTips":["load_dotenv uses the relative path '.env' — run benchmark CLIs from backend/ or export the key explicitly.","Keep a GEMINI_API_KEY entry in the project .env if you run extraction evals."],"tags":["api-key","gemini","cli","env"],"backgroundTag":null,"analyzedSha":"d026163f586dfa8c5c10d28c36edd59a9d3b0e88","analyzedAt":"2026-08-14T22:02:06.951Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}