{"record":{"id":"e23e2cb17e457add","repo":"BerriAI/litellm","slug":"gemini-api-key-is-not-set-e23e2c","errorCode":null,"errorMessage":"GEMINI_API_KEY is not set","messagePattern":"GEMINI_API_KEY is not set","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"litellm/llms/gemini/image_generation/transformation.py","lineNumber":104,"sourceCode":"        else:\n            # All other Imagen models use predict endpoint\n            complete_url = f\"{complete_url}/models/{model}:predict\"\n\n        return complete_url\n\n    def validate_environment(\n        self,\n        headers: dict,\n        model: str,\n        messages: list[AllMessageValues],\n        optional_params: dict,\n        litellm_params: dict,\n        api_key: str | None = None,\n        api_base: str | None = None,\n    ) -> dict:\n        final_api_key: Final[str | None] = api_key or get_secret_str(\"GEMINI_API_KEY\")\n        if not final_api_key:\n            raise ValueError(\"GEMINI_API_KEY is not set\")\n\n        headers[\"x-goog-api-key\"] = final_api_key\n        headers[\"Content-Type\"] = \"application/json\"\n        return headers\n\n    def transform_image_generation_request(\n        self,\n        model: str,\n        prompt: str,\n        optional_params: dict,\n        litellm_params: dict,\n        headers: dict,\n    ) -> dict:\n        \"\"\"\n        Transform the image generation request to Gemini format\n\n        For Gemini 2.5 Flash Image Preview, use the standard Gemini format with response_modalities:\n        {","sourceCodeStart":86,"sourceCodeEnd":122,"githubUrl":"https://github.com/BerriAI/litellm/blob/6c2dcb801bf2b75c18f1bb24140e7cf57465cc4d/litellm/llms/gemini/image_generation/transformation.py#L86-L122","documentation":"Error \"GEMINI_API_KEY is not set\" thrown in BerriAI/litellm.","triggerScenarios":"Thrown at litellm/llms/gemini/image_generation/transformation.py:104 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Set GEMINI_API_KEY in the environment."],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"6c2dcb801bf2b75c18f1bb24140e7cf57465cc4d","analyzedAt":"2026-08-15T07:12:03.035Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}