chroma-core/chroma · error · ValueError

The api_base argument must be provided.

Error message

The api_base argument must be provided.

What it means

api_base is the URL of your Baseten model deployment and is a required constructor argument with no default and no env-var fallback — unlike the API key, it cannot be discovered any other way. The check uses falsiness, so both omitting the argument (None) and passing an empty string raise this ValueError. The value is persisted in get_config(), so once set it survives round-trips.

Source

Thrown at chromadb/utils/embedding_functions/baseten_embedding_function.py:52

                "Direct api_key configuration will not be persisted. "
                "Please use environment variables via api_key_env_var for persistent storage.",
                DeprecationWarning,
            )

        if os.getenv("BASETEN_API_KEY") is not None:
            self.api_key_env_var = "BASETEN_API_KEY"
        else:
            self.api_key_env_var = api_key_env_var

        # Prioritize api_key argument, then environment variable
        resolved_api_key = api_key or os.getenv(self.api_key_env_var)
        if not resolved_api_key:
            raise ValueError(
                f"API key not provided and {self.api_key_env_var} environment variable is not set."
            )
        self.api_key = resolved_api_key
        if not api_base:
            raise ValueError("The api_base argument must be provided.")
        self.api_base = api_base
        self.model_name = "baseten-embedding-model"
        self.dimensions = None

        self.client = openai.OpenAI(api_key=self.api_key, base_url=self.api_base)

    @staticmethod
    def name() -> str:
        return "baseten"

    def default_space(self) -> Space:
        return "cosine"

    def supported_spaces(self) -> List[Space]:
        return ["cosine", "l2", "ip"]

    def get_config(self) -> Dict[str, Any]:
        return {"api_base": self.api_base, "api_key_env_var": self.api_key_env_var}

View on GitHub (pinned to aecdd12c8a)

Solutions

  1. Pass your deployment URL: BasetenEmbeddingFunction(api_base="https://app.baseten.co/en/deployments/<deployment-id>/predict").
  2. Source it from config/env in your own wrapper so every environment supplies it: api_base=os.environ["BASETEN_API_BASE"].
  3. When serializing configs, always use ef.get_config() — it includes api_base so build_from_config never sees it missing.

Example fix

# before: ValueError "The api_base argument must be provided."
ef = BasetenEmbeddingFunction(api_key="bs-...")

# after
import os
ef = BasetenEmbeddingFunction(
    api_base=os.environ["BASETEN_API_BASE"],
    api_key_env_var="CHROMA_BASETEN_API_KEY",
)
Defensive patterns

Strategy: validation

Validate before calling

import os

api_base = os.environ.get("BASETEN_API_BASE")
if not api_base:
    raise RuntimeError("BASETEN_API_BASE must be set to your Baseten deployment URL")

from chromadb.utils.embedding_functions import BasetenEmbeddingFunction
ef = BasetenEmbeddingFunction(api_base=api_base, api_key_env_var="CHROMA_BASETEN_API_KEY")

Type guard

def is_valid_baseten_api_base(value: object) -> bool:
    return isinstance(value, str) and value.startswith(("http://", "https://")) and len(value) > len("https://")

Try / catch

try:
    ef = BasetenEmbeddingFunction(api_base=api_base, api_key_env_var="CHROMA_BASETEN_API_KEY")
except ValueError as e:
    if "api_base argument must be provided" in str(e):
        raise RuntimeError("Configure BASETEN_API_BASE with your deployment URL") from e
    raise

Prevention

When it happens

Trigger: BasetenEmbeddingFunction(api_key="...") with no api_base; passing api_base="" or api_base=None; deserializing a hand-built config whose "api_base" key was dropped (build_from_config catches that earlier with its own message).

Common situations: Copying constructor calls from docs that show only the key; forgetting that Baseten deployments each have their own URL; config templating that leaves api_base empty in non-prod environments.

Related errors


AI-assisted analysis of chroma-core/chroma@aecdd12c8a (2026-08-16). Data as JSON: /api/errors/d6a3722b4dbc94e3. Report an issue: GitHub.