BerriAI/litellm · error · DatabricksException
Missing API Base - A call is being made to LLM Provider but
Error message
Missing API Base - A call is being made to LLM Provider but no api base is set either in the environment variables ({LLM_PROVIDER}_API_KEY) or via params What it means
Raised when a custom Databricks endpoint is used and no api base URL could be resolved after the full chain: explicit api_base argument, DATABRICKS_API_BASE env var, and (for custom endpoints) the SDK fallback which is skipped. Note the message text incorrectly references _API_KEY; the actual missing item is the base URL.
Source
Thrown at litellm/llms/databricks/common_utils.py:364
headers = headers or {}
headers["Authorization"] = f"Bearer {access_token}"
headers["Content-Type"] = "application/json"
elif api_key is None and not headers:
if custom_endpoint is True:
raise DatabricksException(
status_code=400,
message="Missing API Key - A call is being made to LLM Provider but no key is set either in the environment variables ({LLM_PROVIDER}_API_KEY) or via params",
)
else:
# Fallback to Databricks SDK (registers partner telemetry)
verbose_logger.debug("Using Databricks SDK for authentication")
api_base, headers = self._get_databricks_credentials(
api_base=api_base, api_key=api_key, headers=headers
)
if api_base is None:
if custom_endpoint:
raise DatabricksException(
status_code=400,
message="Missing API Base - A call is being made to LLM Provider but no api base is set either in the environment variables ({LLM_PROVIDER}_API_KEY) or via params",
)
else:
api_base, headers = self._get_databricks_credentials(
api_base=api_base, api_key=api_key, headers=headers
)
if headers is None:
headers = {
"Authorization": f"Bearer {api_key}",
"Content-Type": "application/json",
}
else:
if api_key is not None:
headers.update({"Authorization": f"Bearer {api_key}"})
if api_key is not None:View on GitHub (pinned to 6c2dcb801b)
Solutions
- Set DATABRICKS_API_BASE to the full serving-endpoint URL (must include /serving-endpoints for native endpoints)
- Or pass api_base in litellm_params / the completion call
- For gateway URLs, confirm whether the /serving-endpoints suffix should be omitted (follow your gateway's docs)
- Double-check the env var actually exports in the runtime shell/container
Example fix
# before # custom endpoint, base never set # after export DATABRICKS_API_BASE="https://my-gateway.internal/databricks" export DATABRICKS_API_KEY="gw-token"
Defensive patterns
Strategy: validation
Validate before calling
api_base = os.getenv("DATABRICKS_API_BASE") or params.get("api_base")
if custom_endpoint and not api_base:
raise RuntimeError("Custom Databricks endpoint requires api_base (gateway URL)") Try / catch
try:
resp = litellm.completion(model=m, messages=msgs)
except Exception as e:
if "Missing API Base" in str(e):
raise ConfigError("Set DATABRICKS_API_BASE / api_base for the custom endpoint") from e
raise Prevention
- Validate proxy config YAML at deploy time: every databricks/ model must declare api_base
- Remember the message text mentions _API_KEY but the missing field is the base URL — check api_base first
When it happens
Trigger: custom_endpoint=True with no api_base argument, no DATABRICKS_API_BASE in the environment — LiteLLM will not guess a URL for a custom endpoint and raises this 400 before any request.
Common situations: Configuring Databricks-through-gateway where the gateway URL env var was forgotten; renaming env vars during a migration; YAML config indentation errors putting api_base under the wrong key.
Related errors
- Missing API Key - A call is being made to LLM Provider but n
- Either set the DATABRICKS_API_BASE and DATABRICKS_API_KEY en
- If the Databricks base URL and API key are not set, the data
- File not found. blocked_user_list={blocked_user_list}
- model_name not set for LlamaGuard
AI-assisted analysis of BerriAI/litellm@6c2dcb801b (2026-08-15).
Data as JSON: /api/errors/1903c0c920ff79ca.
Report an issue: GitHub.