BerriAI/litellm · error · ValueError

api_base is required

Error message

api_base is required

What it means

BaseVectorStoreConfig.get_complete_url() is marked OPTIONAL for providers that need model names embedded in the URL, but the default implementation still guards its input: it returns api_base unchanged, and raises ValueError('api_base is required') when api_base is None (which would otherwise flow into the HTTP client and fail confusingly). The value comes from litellm_params.api_base, provider defaults, or env vars.

Source

Thrown at litellm/llms/base_llm/vector_store/transformation.py:124

    @abstractmethod
    def validate_environment(self, headers: dict, litellm_params: GenericLiteLLMParams | None) -> dict:
        return {}

    @abstractmethod
    def get_complete_url(
        self,
        api_base: str | None,
        litellm_params: dict,
    ) -> str:
        """
        OPTIONAL

        Get the complete url for the request

        Some providers need `model` in `api_base`
        """
        if api_base is None:
            raise ValueError("api_base is required")
        return api_base

    def get_error_class(self, error_message: str, status_code: int, headers: dict | httpx.Headers) -> BaseLLMException:
        from ..chat.transformation import BaseLLMException

        raise BaseLLMException(
            status_code=status_code,
            message=error_message,
            headers=headers,
        )

    def sign_request(
        self,
        headers: dict,
        optional_params: dict,
        request_data: dict,
        api_base: str,
        api_key: str | None = None,

View on GitHub (pinned to 6c2dcb801b)

Solutions

  1. Pass api_base in the vector-store call or litellm_params (api_base='http://vectordb.internal:8080').
  2. Set the provider's base env var (e.g. export VECTOR_STORE_API_BASE=...) or add api_base to the provider entry in litellm's config.
  3. For a custom vector-store config, override get_complete_url to supply the provider's default endpoint.

Example fix

# before
litellm.acreate_vector_store(provider="myvdb", create_request=req)  # ValueError

# after
litellm.acreate_vector_store(
    provider="myvdb", create_request=req,
    litellm_params={"api_base": "http://vectordb.internal:8080"},
)
Defensive patterns

Strategy: validation

Validate before calling

vs_base = litellm_params.get("api_base") or os.getenv("MYVDB_API_BASE")
if not vs_base:
    raise ValueError("vector store provider requires api_base")

Try / catch

try:
    store = await litellm.acreate_vector_store(provider="myvdb", create_request=req, litellm_params=params)
except ValueError as e:
    if "api_base is required" in str(e):
        raise RuntimeError("vector-store api_base missing in config") from None
    raise

Prevention

When it happens

Trigger: Calling litellm vector-store CRUD (create/get/list vector stores) when no api_base can be resolved — custom vector-store provider without a configured base, missing <PROVIDER>_API_BASE env var, or a proxy config that omits api_base for the vector-store LLM-deployment entry.

Common situations: Wiring litellm to a self-hosted vector-store service and forgetting api_base; adding a new provider to the config.yaml without the api_base field; CI environments missing env vars set locally.

Related errors


AI-assisted analysis of BerriAI/litellm@6c2dcb801b (2026-08-15). Data as JSON: /api/errors/6e4ddb8da13e6e9a. Report an issue: GitHub.