chroma-core/chroma · info · ValueError

Missing 'api_base' in configuration for BasetenEmbeddingFunc

Error message

Missing 'api_base' in configuration for BasetenEmbeddingFunction.

What it means

This is a redundant second check in BasetenEmbeddingFunction.build_from_config: the immediately preceding combined check (lines 86-89) already raised when api_base is None, so the `if api_base is None` at line 94 can never be true. As shipped, this branch is unreachable dead code — users who see the message "Missing 'api_base' in configuration..." actually hit the earlier combined check. Its remediation is therefore identical to the line-87 error.

Source

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

        Args:
            config (Dict[str, Any]): A dictionary containing the configuration parameters.
                                     Expected keys: 'api_key', 'api_base', 'api_key_env_var'.

        Returns:
            BasetenEmbeddingFunction: An instance of BasetenEmbeddingFunction.
        """
        api_key_env_var = config.get("api_key_env_var")
        api_base = config.get("api_base")
        if api_key_env_var is None or api_base is None:
            raise ValueError(
                "Missing 'api_key_env_var' or 'api_base' in configuration for BasetenEmbeddingFunction."
            )

        # Note: We rely on the __init__ method to handle potential missing api_key
        # by checking the environment variable if the config value is None.
        # However, api_base must be present either in config or have a default.
        if api_base is None:
            raise ValueError(
                "Missing 'api_base' in configuration for BasetenEmbeddingFunction."
            )

        return BasetenEmbeddingFunction(
            api_key=None,  # Pass None if not in config, __init__ will check env var
            api_base=api_base,
            api_key_env_var=api_key_env_var,
        )

    @staticmethod
    def validate_config(config: Dict[str, Any]) -> None:
        """
        Validate the configuration using the JSON schema.

        Args:
            config: Configuration to validate

        Raises:

View on GitHub (pinned to aecdd12c8a)

Solutions

  1. If you encountered this message at runtime, you actually hit the earlier check — fix the config to include both api_key_env_var and api_base (see the line-87 error).
  2. Upstream cleanup: delete the unreachable second check or merge it into the first so there is one authoritative message.
  3. No action needed otherwise; this path cannot execute.
Defensive patterns

Strategy: validation

Validate before calling

# The raise at this line is unreachable; guard against the real (line-87) check instead
if not ("api_key_env_var" in cfg and "api_base" in cfg):
    raise ValueError("baseten config requires api_key_env_var and api_base")
ef = config_to_embedding_function({"name": "baseten", "config": cfg})

Type guard

def is_complete_baseten_config(cfg: object) -> bool:
    return isinstance(cfg, dict) and "api_key_env_var" in cfg and "api_base" in cfg

Try / catch

try:
    ef = config_to_embedding_function(cfg)
except ValueError as e:
    if "api_base" in str(e) or "api_key_env_var" in str(e):
        raise RuntimeError("Incomplete baseten config: supply both api_base and api_key_env_var") from e
    raise

Prevention

When it happens

Trigger: No code path in the current version can trigger this raise; it would only fire if the combined check above it were removed or relaxed in a future edit.

Common situations: Developers or static analyzers grepping the message find two raise sites and waste time distinguishing them; code-coverage tools report the line as uncovered.

Related errors


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