{"record":{"id":"e441ae4024c53e98","repo":"BerriAI/litellm","slug":"required-gemini-api-key-google-api-key-in-envi","errorCode":null,"errorMessage":"Required 'GEMINI_API_KEY'/'GOOGLE_API_KEY' in environment to make pass-through calls to Google AI Studio.","messagePattern":"Required 'GEMINI_API_KEY'/'GOOGLE_API_KEY' in environment to make pass-through calls to Google AI Studio\\.","errorType":"exception","errorClass":"Exception","httpStatus":500,"severity":"error","filePath":"litellm/proxy/pass_through_endpoints/llm_passthrough_endpoints.py","lineNumber":223,"sourceCode":"\n    # Ensure endpoint starts with '/' for proper URL construction\n    if not encoded_endpoint.startswith(\"/\"):\n        encoded_endpoint = \"/\" + encoded_endpoint\n\n    # Construct the full target URL using httpx, preserving any base path\n    # prefix that the operator configured on base_target_url.\n    base_url: Final = httpx.URL(base_target_url)\n    updated_url: Final = base_url.copy_with(\n        path=HttpPassThroughEndpointHelpers.join_base_and_endpoint_path(base_url, encoded_endpoint)\n    )\n\n    # Add or update query parameters\n    gemini_api_key: Final[str | None] = passthrough_endpoint_router.get_credentials(\n        custom_llm_provider=\"gemini\",\n        region_name=None,\n    )\n    if gemini_api_key is None:\n        raise Exception(\n            \"Required 'GEMINI_API_KEY'/'GOOGLE_API_KEY' in environment to make pass-through calls to Google AI Studio.\"\n        )\n    # Merge query parameters, giving precedence to those in updated_url\n    merged_params: Final = dict(request.query_params)\n    merged_params.update({\"key\": gemini_api_key})\n\n    ## check for streaming\n    is_streaming_request = False\n    if \"stream\" in str(updated_url):\n        is_streaming_request = True\n\n    ## CREATE PASS-THROUGH\n    endpoint_func: Final = create_pass_through_route(\n        endpoint=endpoint,\n        target=str(updated_url),\n        custom_llm_provider=\"gemini\",\n        is_streaming_request=is_streaming_request,\n        query_params=merged_params,","sourceCodeStart":205,"sourceCodeEnd":241,"githubUrl":"https://github.com/BerriAI/litellm/blob/77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8/litellm/proxy/pass_through_endpoints/llm_passthrough_endpoints.py#L205-L241","documentation":"HTTPException raised on the Google AI Studio pass-through route: neither GEMINI_API_KEY nor GOOGLE_API_KEY is present in the environment (or resolvable via the passthrough route lock), so the proxied request to Google cannot be authenticated. The admin must set one of these variables.","triggerScenarios":"Thrown at litellm/proxy/pass_through_endpoints/llm_passthrough_endpoints.py:223 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Set GEMINI_API_KEY or GOOGLE_API_KEY in the proxy environment before calling the Gemini pass-through endpoint.","Alternatively configure the credential on the model/vector store entry in config.yaml so the pass-through route can resolve it."],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8","analyzedAt":"2026-08-18T11:44:31.656Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}