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
- Pass your deployment URL: BasetenEmbeddingFunction(api_base="https://app.baseten.co/en/deployments/<deployment-id>/predict").
- Source it from config/env in your own wrapper so every environment supplies it: api_base=os.environ["BASETEN_API_BASE"].
- 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
- Source api_base from configuration in every environment (dev/staging/prod each have distinct deployment URLs).
- Fail fast at startup on missing BASETEN_API_BASE instead of at first embed.
- Persist it via get_config() so restored collections keep working.
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
- Config must contain a 'name' field.
- The openai python package is not installed. Please install i
- Unequal lengths for fields: {error_str}
- Attempting to embed a record that already has embeddings.
- At least one of {', '.join(contains_any)} must be provided
AI-assisted analysis of chroma-core/chroma@aecdd12c8a (2026-08-16).
Data as JSON: /api/errors/d6a3722b4dbc94e3.
Report an issue: GitHub.