BerriAI/litellm · error · HerokuError
No api base was set. Please provide an api_base, or set the
Error message
No api base was set. Please provide an api_base, or set the HEROKU_API_BASE environment variable.
What it means
Raised by HerokuChatConfig.get_complete_url when neither an explicit api_base nor the HEROKU_API_BASE environment variable is present. Unlike cloud providers with fixed endpoints, Heroku AI deployments are per-app, so LiteLLM cannot construct a URL without being told where your inference endpoint lives; it raises HerokuError instead of guessing.
Source
Thrown at litellm/llms/heroku/chat/transformation.py:70
) -> tuple[str | None, str | None]:
api_base = api_base or os.getenv("HEROKU_API_BASE")
api_key = api_key or os.getenv("HEROKU_API_KEY")
return api_base, api_key
def get_complete_url(
self,
api_base: str | None,
api_key: str | None,
model: str,
optional_params: dict,
litellm_params: dict,
stream: bool | None = None,
) -> str:
api_base, _ = self._get_openai_compatible_provider_info(api_base, api_key)
if not api_base:
raise HerokuError(
"No api base was set. Please provide an api_base, or set the HEROKU_API_BASE environment variable."
)
if not api_base.endswith("/v1/chat/completions"):
api_base = f"{api_base}/v1/chat/completions"
return api_base
View on GitHub (pinned to 6c2dcb801b)
Solutions
- Set the env var: export HEROKU_API_BASE=https://<your-heroku-app>.herokuapp.com
- Or pass api_base per call: litellm.completion(model='heroku/...', api_base='https://<app>.herokuapp.com', api_key=...).
- Confirm the URL is your Heroku inference addon endpoint (the code will append /v1/chat/completions automatically if missing), so supply the bare app URL.
Example fix
# before
litellm.completion(model='heroku/claire-3.5-sonnet', messages=msgs, api_key=os.environ['HEROKU_API_KEY'])
# raises HerokuError: No api base was set
# after
litellm.completion(
model='heroku/claire-3.5-sonnet',
messages=msgs,
api_base=os.environ['HEROKU_API_BASE'], # https://us.inference.heroku.com
api_key=os.environ['HEROKU_API_KEY'],
)
Defensive patterns
Strategy: validation
Validate before calling
import os
def heroku_base(api_base: str | None = None) -> str:
base = api_base or os.environ.get("HEROKU_API_BASE")
if not base:
raise ValueError("HEROKU_API_BASE not set — configure it before calling heroku models")
return base Try / catch
try:
litellm.completion(model="heroku/...", messages=msgs, api_base=base, api_key=key)
except Exception as e:
if "No api base was set" in str(e):
raise RuntimeError("Missing HEROKU_API_BASE — check deployment env") from e
raise Prevention
- Add HEROKU_API_BASE alongside HEROKU_API_KEY in every environment that calls heroku models.
- Fail fast at startup: assert required env vars for each provider you enable.
When it happens
Trigger: Calling litellm.completion(model='heroku/<model>') without api_base and without HEROKU_API_BASE set. Note the code first calls _get_openai_compatible_provider_info, which reads env vars like HEROKU_API_BASE; if none resolve, api_base is falsy and this raises.
Common situations: Assuming Heroku has a shared API host like OpenAI; forgetting the endpoint URL differs per Heroku app; deploying to a new environment where HEROKU_API_BASE was not injected; passing api_key but not api_base.
Related errors
- api_base is required for hosted_vllm embeddings
- api_base not set for Hosted VLLM responses API. Set via api_
- API base is required for OpenAI image variations
- API base is required for Topaz image variations
- api_key is required for Azure AI Speech transcription.
AI-assisted analysis of BerriAI/litellm@6c2dcb801b (2026-08-15).
Data as JSON: /api/errors/1cb7276460b791a4.
Report an issue: GitHub.