BerriAI/litellm · error · ValueError

GEMINI_API_BASE is not set

Error message

GEMINI_API_BASE is not set

What it means

Error "GEMINI_API_BASE is not set" thrown in BerriAI/litellm.

Solutions

  1. Set the GEMINI_API_BASE environment variable, or pass api_base explicitly.

When it happens

Trigger: Thrown at litellm/llms/gemini/vector_stores/transformation.py:91 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of BerriAI/litellm@77b7c6c40c (2026-08-18). Data as JSON: /api/errors/c97a53b410c7a382. Report an issue: GitHub.

Appendix: source

Thrown at litellm/llms/gemini/vector_stores/transformation.py:91

            api_key: Final = litellm_params.get("api_key") or get_api_key_from_env()
            if api_key:
                self._cached_api_key = api_key
                headers["x-goog-api-key"] = api_key

        return headers

    def get_complete_url(self, api_base: str | None, litellm_params: dict) -> str:
        """
        Get the complete base URL for Gemini API.

        Note: This returns the base URL WITHOUT the API key.
        The API key will be appended to specific endpoint URLs in the transform methods.
        """
        if api_base is None:
            api_base = GeminiModelInfo.get_api_base()

        if api_base is None:
            raise ValueError("GEMINI_API_BASE is not set")

        # Ensure we're using the v1beta version for File Search
        api_version: Final = "v1beta"
        return f"{api_base}/{api_version}"

    def get_error_class(self, error_message: str, status_code: int, headers: dict | httpx.Headers) -> GeminiError:
        """Return Gemini-specific error class."""
        return GeminiError(
            status_code=status_code,
            message=error_message,
            headers=headers,
        )

    def transform_search_vector_store_request(
        self,
        vector_store_id: str,
        query: str | list[str],
        vector_store_search_optional_params: VectorStoreSearchOptionalRequestParams,

View on GitHub (pinned to 77b7c6c40c)