{"record":{"id":"1cb7276460b791a4","repo":"BerriAI/litellm","slug":"no-api-base-was-set-please-provide-an-api-base-o","errorCode":null,"errorMessage":"No api base was set. Please provide an api_base, or set the HEROKU_API_BASE environment variable.","messagePattern":"No api base was set\\. Please provide an api_base, or set the HEROKU_API_BASE environment variable\\.","errorType":"exception","errorClass":"HerokuError","httpStatus":null,"severity":"error","filePath":"litellm/llms/heroku/chat/transformation.py","lineNumber":70,"sourceCode":"    ) -> tuple[str | None, str | None]:\n        api_base = api_base or os.getenv(\"HEROKU_API_BASE\")\n        api_key = api_key or os.getenv(\"HEROKU_API_KEY\")\n\n        return api_base, api_key\n\n    def get_complete_url(\n        self,\n        api_base: str | None,\n        api_key: str | None,\n        model: str,\n        optional_params: dict,\n        litellm_params: dict,\n        stream: bool | None = None,\n    ) -> str:\n        api_base, _ = self._get_openai_compatible_provider_info(api_base, api_key)\n\n        if not api_base:\n            raise HerokuError(\n                \"No api base was set. Please provide an api_base, or set the HEROKU_API_BASE environment variable.\"\n            )\n\n        if not api_base.endswith(\"/v1/chat/completions\"):\n            api_base = f\"{api_base}/v1/chat/completions\"\n\n        return api_base\n","sourceCodeStart":52,"sourceCodeEnd":78,"githubUrl":"https://github.com/BerriAI/litellm/blob/6c2dcb801bf2b75c18f1bb24140e7cf57465cc4d/litellm/llms/heroku/chat/transformation.py#L52-L78","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":"# before\nlitellm.completion(model='heroku/claire-3.5-sonnet', messages=msgs, api_key=os.environ['HEROKU_API_KEY'])\n# raises HerokuError: No api base was set\n\n# after\nlitellm.completion(\n    model='heroku/claire-3.5-sonnet',\n    messages=msgs,\n    api_base=os.environ['HEROKU_API_BASE'],  # https://us.inference.heroku.com\n    api_key=os.environ['HEROKU_API_KEY'],\n)\n","handlingStrategy":"validation","validationCode":"import os\n\ndef heroku_base(api_base: str | None = None) -> str:\n    base = api_base or os.environ.get(\"HEROKU_API_BASE\")\n    if not base:\n        raise ValueError(\"HEROKU_API_BASE not set — configure it before calling heroku models\")\n    return base","typeGuard":null,"tryCatchPattern":"try:\n    litellm.completion(model=\"heroku/...\", messages=msgs, api_base=base, api_key=key)\nexcept Exception as e:\n    if \"No api base was set\" in str(e):\n        raise RuntimeError(\"Missing HEROKU_API_BASE — check deployment env\") from e\n    raise","preventionTips":["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."],"tags":["heroku","configuration","api-base","env-vars"],"backgroundTag":null,"analyzedSha":"6c2dcb801bf2b75c18f1bb24140e7cf57465cc4d","analyzedAt":"2026-08-15T07:12:03.035Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}