{"record":{"id":"777981c528c26d78","repo":"BerriAI/litellm","slug":"google-api-key-is-required-set-google-api-key-or-777981","errorCode":null,"errorMessage":"Google API key is required. Set GOOGLE_API_KEY or GEMINI_API_KEY environment variable.","messagePattern":"Google API key is required\\. Set GOOGLE_API_KEY or GEMINI_API_KEY environment variable\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"litellm/llms/gemini/interactions/transformation.py","lineNumber":116,"sourceCode":"            headers[\"Api-Revision\"] = \"2026-05-20\"\n\n        return headers\n\n    def get_complete_url(\n        self,\n        api_base: str | None,\n        model: str | None,\n        agent: str | None = None,\n        litellm_params: dict | None = None,\n        stream: bool | None = None,\n    ) -> str:\n        \"\"\"POST /{api_version}/interactions\"\"\"\n        litellm_params = litellm_params or {}\n        api_base = GeminiModelInfo.get_api_base(api_base)\n        api_key: Final = GeminiModelInfo.get_api_key(litellm_params.get(\"api_key\"))\n\n        if not api_key:\n            raise ValueError(\"Google API key is required. Set GOOGLE_API_KEY or GEMINI_API_KEY environment variable.\")\n\n        if stream:\n            return f\"{api_base}/{self.api_version}/interactions?alt=sse\"\n\n        return f\"{api_base}/{self.api_version}/interactions\"\n\n    def transform_request(\n        self,\n        model: str | None,\n        agent: str | None,\n        input: InteractionInput | None,\n        optional_params: InteractionsAPIOptionalRequestParams,\n        litellm_params: GenericLiteLLMParams,\n        headers: dict,\n    ) -> dict:\n        \"\"\"\n        Build request body per OpenAPI spec.\n","sourceCodeStart":98,"sourceCodeEnd":134,"githubUrl":"https://github.com/BerriAI/litellm/blob/77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8/litellm/llms/gemini/interactions/transformation.py#L98-L134","documentation":"Raised while building the URL for the Gemini Interactions API (POST /v1beta/interactions, used by litellm.interactions.create). GeminiModelInfo.get_api_key resolves litellm_params['api_key'], then the GOOGLE_API_KEY env var, then GEMINI_API_KEY; if all are empty the request is aborted before it starts. Note this path (unlike the image handlers) does accept GOOGLE_API_KEY.","triggerScenarios":"litellm.interactions.create(model='gemini-2.5-flash', input=...) with no api_key in litellm_params and neither GOOGLE_API_KEY nor GEMINI_API_KEY in the environment; streaming creates hit the same check before the ?alt=sse URL is built.","commonSituations":"New Interactions-API integrations where env vars were wired for other providers only; serverless/cold-start processes missing env config; keys stored in a vault but not exported into the process.","solutions":["export GOOGLE_API_KEY=... or GEMINI_API_KEY=... before starting the process","Or pass api_key via litellm_params: litellm.interactions.create(..., api_key=KEY)","Confirm with: python -c \"from litellm.llms.gemini.common_utils import GeminiModelInfo; print(bool(GeminiModelInfo.get_api_key()))\"","In containers, verify the env var exists inside the running process (printenv)"],"exampleFix":"# before\nr = litellm.interactions.create(model='gemini-2.5-flash', input={'text': 'hi'})\n# ValueError: Google API key is required. Set GOOGLE_API_KEY or GEMINI_API_KEY environment variable.\n\n# after\nr = litellm.interactions.create(\n    model='gemini-2.5-flash',\n    input={'text': 'hi'},\n    api_key=os.environ['GOOGLE_API_KEY'],\n)","handlingStrategy":"validation","validationCode":"from litellm.llms.gemini.common_utils import GeminiModelInfo\n\nassert GeminiModelInfo.get_api_key(), \\\n    'interactions.create needs api_key or GOOGLE_API_KEY/GEMINI_API_KEY in env'","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Export GOOGLE_API_KEY/GEMINI_API_KEY in every service that creates interactions","Pass api_key explicitly from your secret store rather than trusting ambient env","Fail fast at startup with GeminiModelInfo.get_api_key() checks"],"tags":["gemini","interactions-api","authentication","missing-api-key"],"backgroundTag":"missing-api-key","analyzedSha":"77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8","analyzedAt":"2026-08-18T11:44:31.656Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}