{"record":{"id":"c97a53b410c7a382","repo":"BerriAI/litellm","slug":"gemini-api-base-is-not-set","errorCode":null,"errorMessage":"GEMINI_API_BASE is not set","messagePattern":"GEMINI_API_BASE is not set","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"litellm/llms/gemini/vector_stores/transformation.py","lineNumber":91,"sourceCode":"            api_key: Final = litellm_params.get(\"api_key\") or get_api_key_from_env()\n            if api_key:\n                self._cached_api_key = api_key\n                headers[\"x-goog-api-key\"] = api_key\n\n        return headers\n\n    def get_complete_url(self, api_base: str | None, litellm_params: dict) -> str:\n        \"\"\"\n        Get the complete base URL for Gemini API.\n\n        Note: This returns the base URL WITHOUT the API key.\n        The API key will be appended to specific endpoint URLs in the transform methods.\n        \"\"\"\n        if api_base is None:\n            api_base = GeminiModelInfo.get_api_base()\n\n        if api_base is None:\n            raise ValueError(\"GEMINI_API_BASE is not set\")\n\n        # Ensure we're using the v1beta version for File Search\n        api_version: Final = \"v1beta\"\n        return f\"{api_base}/{api_version}\"\n\n    def get_error_class(self, error_message: str, status_code: int, headers: dict | httpx.Headers) -> GeminiError:\n        \"\"\"Return Gemini-specific error class.\"\"\"\n        return GeminiError(\n            status_code=status_code,\n            message=error_message,\n            headers=headers,\n        )\n\n    def transform_search_vector_store_request(\n        self,\n        vector_store_id: str,\n        query: str | list[str],\n        vector_store_search_optional_params: VectorStoreSearchOptionalRequestParams,","sourceCodeStart":73,"sourceCodeEnd":109,"githubUrl":"https://github.com/BerriAI/litellm/blob/6c2dcb801bf2b75c18f1bb24140e7cf57465cc4d/litellm/llms/gemini/vector_stores/transformation.py#L73-L109","documentation":"Raised in the Gemini File Search / vector-store config's get_complete_url when no API base can be resolved: the api_base argument is None and GeminiModelInfo.get_api_base() (which reads GEMINI_API_BASE env / default config) also returns None. Because the URL cannot be constructed, the call fails before authentication.","triggerScenarios":"Using litellm's vector_store/file-search API with the Gemini provider, passing no api_base, and having no GEMINI_API_BASE environment variable (nor the default base registered) available.","commonSituations":"Air-gapped or self-hosted setups where the default generativelanguage.googleapis.com base is not configured; env var set only in some services of a deployment; typo'd GEMINI_API_BASE name; Vertex-based users missing a base override.","solutions":["Set GEMINI_API_BASE (e.g. https://generativelanguage.googleapis.com) in the environment.","Pass api_base explicitly on the vector-store call: litellm.vector_store_search(..., api_base='https://generativelanguage.googleapis.com').","For Vertex-style deployments, provide the appropriate regional base URL your setup expects."],"exampleFix":"# before\nresults = litellm.vector_store_search(vector_store_id=vs_id, query='hello', litellm_params={'model': 'gemini/gemini-2.5-flash'})\n\n# after\nimport os\nos.environ['GEMINI_API_BASE'] = 'https://generativelanguage.googleapis.com'\nresults = litellm.vector_store_search(vector_store_id=vs_id, query='hello', litellm_params={'model': 'gemini/gemini-2.5-flash', 'api_base': os.environ['GEMINI_API_BASE']})\n","handlingStrategy":"validation","validationCode":"import os\n\ndef resolve_gemini_api_base(api_base=None) -> str:\n    base = api_base or os.environ.get(\"GEMINI_API_BASE\") or \"https://generativelanguage.googleapis.com\"\n    if not base:\n        raise ConfigError(\"GEMINI_API_BASE not configured\")\n    return base","typeGuard":null,"tryCatchPattern":"try:\n    results = litellm.vector_store_search(vector_store_id=vs, query=q, litellm_params=params)\nexcept ValueError as e:\n    if \"GEMINI_API_BASE is not set\" in str(e):\n        raise ConfigError(\"Set GEMINI_API_BASE for Gemini File Search\") from e\n    raise","preventionTips":["Set GEMINI_API_BASE explicitly in every environment using Gemini file search.","Default the base URL in your own wrapper so a missing env var never reaches litellm.","Include a file-search call in deploy-time smoke tests."],"tags":["gemini","vector-stores","config","api-base","file-search"],"backgroundTag":null,"analyzedSha":"6c2dcb801bf2b75c18f1bb24140e7cf57465cc4d","analyzedAt":"2026-08-15T07:12:03.035Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}