BerriAI/litellm · error · ValueError

api_base is required

Error message

api_base is required

What it means

BaseVectorStoreFilesConfig.get_complete_url() builds the URL for vector-store-file operations. Its default implementation returns api_base unchanged but first asserts it is not None, raising ValueError('api_base is required'). Without the guard a None base would produce 'None/vector_stores/.../files' and fail much later with a confusing HTTP error.

Source

Thrown at litellm/llms/base_llm/vector_store_files/transformation.py:80

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

    @abstractmethod
    def get_complete_url(
        self,
        *,
        api_base: str | None,
        vector_store_id: str,
        litellm_params: dict[str, Any],
    ) -> str:
        if api_base is None:
            raise ValueError("api_base is required")
        return api_base

    @abstractmethod
    def transform_create_vector_store_file_request(
        self,
        *,
        vector_store_id: str,
        create_request: VectorStoreFileCreateRequest,
        api_base: str,
    ) -> tuple[str, dict[str, Any]]: ...

    @abstractmethod
    def transform_create_vector_store_file_response(
        self,
        *,
        response: httpx.Response,
    ) -> VectorStoreFileObject: ...

View on GitHub (pinned to 6c2dcb801b)

Solutions

  1. Pass api_base via litellm_params on the file call.
  2. Set the provider's API-base env var or add api_base to the provider's vector-store config in litellm's config file.
  3. Override get_complete_url in a custom config to encode the provider's real file endpoint.

Example fix

# before
await litellm.acreate_vector_store_file(
    vector_store_id="vs_123", provider="myvdb", create_request=body,  # ValueError
)

# after
await litellm.acreate_vector_store_file(
    vector_store_id="vs_123", provider="myvdb", create_request=body,
    litellm_params={"api_base": "http://vectordb.internal:8080"},
)
Defensive patterns

Strategy: validation

Validate before calling

if not litellm_params.get("api_base") and not os.getenv("MYVDB_API_BASE"):
    raise ValueError("vector-store file ops require api_base")

Try / catch

try:
    f = await litellm.acreate_vector_store_file(vector_store_id=vid, provider=p, create_request=body)
except ValueError as e:
    if "api_base is required" in str(e):
        raise RuntimeError("set MYVDB_API_BASE or litellm_params['api_base']") from None
    raise

Prevention

When it happens

Trigger: Calling vector-store file CRUD (create/get/delete a file within a store) when api_base is unresolvable — no litellm_params.api_base, no provider default, no env var set.

Common situations: Self-hosted vector DB backends wired into litellm without api_base in the deployment config; env vars missing in containers/CI; provider config entries created by copying a chat-model template that lacks vector-store fields.

Related errors


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