{"record":{"id":"d6a3722b4dbc94e3","repo":"chroma-core/chroma","slug":"the-api-base-argument-must-be-provided","errorCode":null,"errorMessage":"The api_base argument must be provided.","messagePattern":"The api_base argument must be provided\\.","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"chromadb/utils/embedding_functions/baseten_embedding_function.py","lineNumber":52,"sourceCode":"                \"Direct api_key configuration will not be persisted. \"\n                \"Please use environment variables via api_key_env_var for persistent storage.\",\n                DeprecationWarning,\n            )\n\n        if os.getenv(\"BASETEN_API_KEY\") is not None:\n            self.api_key_env_var = \"BASETEN_API_KEY\"\n        else:\n            self.api_key_env_var = api_key_env_var\n\n        # Prioritize api_key argument, then environment variable\n        resolved_api_key = api_key or os.getenv(self.api_key_env_var)\n        if not resolved_api_key:\n            raise ValueError(\n                f\"API key not provided and {self.api_key_env_var} environment variable is not set.\"\n            )\n        self.api_key = resolved_api_key\n        if not api_base:\n            raise ValueError(\"The api_base argument must be provided.\")\n        self.api_base = api_base\n        self.model_name = \"baseten-embedding-model\"\n        self.dimensions = None\n\n        self.client = openai.OpenAI(api_key=self.api_key, base_url=self.api_base)\n\n    @staticmethod\n    def name() -> str:\n        return \"baseten\"\n\n    def default_space(self) -> Space:\n        return \"cosine\"\n\n    def supported_spaces(self) -> List[Space]:\n        return [\"cosine\", \"l2\", \"ip\"]\n\n    def get_config(self) -> Dict[str, Any]:\n        return {\"api_base\": self.api_base, \"api_key_env_var\": self.api_key_env_var}","sourceCodeStart":34,"sourceCodeEnd":70,"githubUrl":"https://github.com/chroma-core/chroma/blob/aecdd12c8a891610db8653630b066b32ceb678b5/chromadb/utils/embedding_functions/baseten_embedding_function.py#L34-L70","documentation":"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.","triggerScenarios":"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).","commonSituations":"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.","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."],"exampleFix":"# before: ValueError \"The api_base argument must be provided.\"\nef = BasetenEmbeddingFunction(api_key=\"bs-...\")\n\n# after\nimport os\nef = BasetenEmbeddingFunction(\n    api_base=os.environ[\"BASETEN_API_BASE\"],\n    api_key_env_var=\"CHROMA_BASETEN_API_KEY\",\n)","handlingStrategy":"validation","validationCode":"import os\n\napi_base = os.environ.get(\"BASETEN_API_BASE\")\nif not api_base:\n    raise RuntimeError(\"BASETEN_API_BASE must be set to your Baseten deployment URL\")\n\nfrom chromadb.utils.embedding_functions import BasetenEmbeddingFunction\nef = BasetenEmbeddingFunction(api_base=api_base, api_key_env_var=\"CHROMA_BASETEN_API_KEY\")","typeGuard":"def is_valid_baseten_api_base(value: object) -> bool:\n    return isinstance(value, str) and value.startswith((\"http://\", \"https://\")) and len(value) > len(\"https://\")","tryCatchPattern":"try:\n    ef = BasetenEmbeddingFunction(api_base=api_base, api_key_env_var=\"CHROMA_BASETEN_API_KEY\")\nexcept ValueError as e:\n    if \"api_base argument must be provided\" in str(e):\n        raise RuntimeError(\"Configure BASETEN_API_BASE with your deployment URL\") from e\n    raise","preventionTips":["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."],"tags":["python","baseten","required-argument","embedding-functions","validation","chromadb"],"backgroundTag":"missing-required-parameter","analyzedSha":"aecdd12c8a891610db8653630b066b32ceb678b5","analyzedAt":"2026-08-16T21:53:27.228Z","schemaVersion":2},"datasetVersion":"2026-08-16T23:17:17.608Z"}