{"record":{"id":"b2c4e7ea597919b0","repo":"BerriAI/litellm","slug":"google-api-key-is-required","errorCode":null,"errorMessage":"Google API key is required","messagePattern":"Google API key is required","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"litellm/llms/gemini/interactions/transformation.py","lineNumber":280,"sourceCode":"        logging_obj: LiteLLMLoggingObj,\n    ) -> InteractionsAPIStreamingResponse:\n        \"\"\"Parse streaming chunk.\"\"\"\n        verbose_logger.debug(\"Google AI Interactions streaming chunk: %s\", parsed_chunk)\n        return InteractionsAPIStreamingResponse(**parsed_chunk)\n\n    # GET / DELETE / CANCEL - just build URLs, responses match spec directly\n\n    def transform_get_interaction_request(\n        self,\n        interaction_id: str,\n        api_base: str,\n        litellm_params: GenericLiteLLMParams,\n        headers: dict,\n    ) -> tuple[str, dict]:\n        \"\"\"GET /{api_version}/interactions/{interaction_id}\"\"\"\n        resolved_api_base: Final = GeminiModelInfo.get_api_base(api_base)\n        if not GeminiModelInfo.get_api_key(litellm_params.api_key):\n            raise ValueError(\"Google API key is required\")\n        encoded_interaction_id: Final = encode_url_path_segment(interaction_id, field_name=\"interaction_id\")\n        return (\n            f\"{resolved_api_base}/{self.api_version}/interactions/{encoded_interaction_id}\",\n            {},\n        )\n\n    def transform_get_interaction_response(\n        self,\n        raw_response: httpx.Response,\n        logging_obj: LiteLLMLoggingObj,\n    ) -> InteractionsAPIResponse:\n        try:\n            raw_json: Final = raw_response.json()\n        except Exception:\n            raise GeminiError(\n                message=raw_response.text,\n                status_code=raw_response.status_code,\n                headers=dict(raw_response.headers),","sourceCodeStart":262,"sourceCodeEnd":298,"githubUrl":"https://github.com/BerriAI/litellm/blob/77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8/litellm/llms/gemini/interactions/transformation.py#L262-L298","documentation":"Raised by GoogleAIStudioInteractionsConfig.transform_get_interaction_request before a GET (and the sibling DELETE/CANCEL builders) on /v1beta/interactions/{id}. It resolves the key via GeminiModelInfo.get_api_key(litellm_params.api_key): explicit value, then GOOGLE_API_KEY, then GEMINI_API_KEY. If none is present the lookup URL is never built. Unlike the create-path error, this message carries no env-var hint.","triggerScenarios":"litellm.interactions.get / delete / cancel calls (polling a background interaction, cleaning up stored interaction ids) with no api_key in litellm_params and neither GOOGLE_API_KEY nor GEMINI_API_KEY exported.","commonSituations":"Poller/cleanup workers running in a different process (queue consumer, cron) than the creator and missing env config; storing interaction ids but not credentials context; serverless functions with sparse env.","solutions":["export GOOGLE_API_KEY=... (or GEMINI_API_KEY) in every process that touches interactions, including pollers","Or pass api_key on each get/delete/cancel call so it lands in litellm_params","Share one key-resolution helper across your create and poll paths so they cannot drift","Verify: python -c \"from litellm.llms.gemini.common_utils import GeminiModelInfo; print(bool(GeminiModelInfo.get_api_key()))\""],"exampleFix":"# before\nr = litellm.interactions.get(interaction_id=stored_id)\n# ValueError: Google API key is required\n\n# after\nr = litellm.interactions.get(\n    interaction_id=stored_id,\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    'interaction get/delete/cancel needs api_key in litellm_params or GOOGLE_API_KEY/GEMINI_API_KEY'","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Give poller/cleanup workers the same key configuration as creators","Pass api_key explicitly on every interactions get/delete/cancel call","Add a startup key check to background workers that poll interactions"],"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"}