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
After all resolution paths, api_base is still None while custom_endpoint is true, so no SDK fallback is attempted and LiteLLM raises 400 'Missing API Base'. Be aware the shipped message contains a copy-paste bug: it says '{LLM_PROVIDER}_API_KEY' where it means the API _BASE_ — the missing value is the base URL, not the key.
Solutions
- Provide the base URL: export DATABRICKS_API_BASE=https://<workspace-host>/serving-endpoints, or api_base= on the call/deployment
- Ignore the '_API_KEY' wording — it is a known message bug; the missing item is the API base
- If you expected SDK-derived auth, remove the custom-endpoint configuration so the SDK fallback can resolve the host
Example fix
# before
os.environ.pop('DATABRICKS_API_BASE', None)
litellm.completion(model='databricks/my-model', messages=msgs) # 400 'Missing API Base'
# after
os.environ['DATABRICKS_API_BASE'] = 'https://adb-1234.0.azuredatabricks.net/serving-endpoints'
litellm.completion(model='databricks/my-model', messages=msgs) Defensive patterns
Strategy: validation
Validate before calling
import os
def databricks_base_set(api_base: str | None) -> bool:
return api_base is not None or bool(os.getenv('DATABRICKS_API_BASE'))
if not databricks_base_set(cfg.get('api_base')):
raise RuntimeError('custom databricks endpoint requires api_base or DATABRICKS_API_BASE') Try / catch
try:
litellm.completion(model='databricks/my-model', messages=msgs)
except Exception as e:
if 'Missing API Base' in str(e):
raise ConfigError('set DATABRICKS_API_BASE (note: error text mentions _API_KEY, that is a litellm message bug)') from e
raise Prevention
- Remember the message text says _API_KEY but means _API_BASE - do not chase the wrong config
- Lint deployment configs so every custom endpoint defines api_base explicitly
When it happens
Trigger: Custom-endpoint Databricks invocation with no api_base argument, no DATABRICKS_API_BASE env var (or a misspelled variant like DATABRICKS_HOST which this code does not read), and the SDK path unavailable — the custom_endpoint flag blocks the fallback that would otherwise derive the host.
Common situations: Router/proxy deployment YAML missing the api_base field; container launched without the env var; copy-pasted configs where the base was replaced by a placeholder; developers misled by the '_API_KEY' wording in the message and re-setting the key instead.
Related errors
- api_base is required
- api_base is required
- api_base is required for hosted_vllm embeddings
- api_base is required for LangFlow. Set it via…
- api_base is required for LangGraph. Set it via…
AI-assisted analysis of BerriAI/litellm@77b7c6c40c (2026-08-18).
Data as JSON: /api/errors/1903c0c920ff79ca.
Report an issue: GitHub.
Appendix: 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 77b7c6c40c)