{"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/77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8/litellm/llms/heroku/chat/transformation.py#L52-L78","documentation":"Heroku's chat completion integration in LiteLLM is OpenAI-compatible but has no default base URL. In get_complete_url(), _get_openai_compatible_provider_info() resolves the api_base argument against the HEROKU_API_BASE environment variable; if both are empty, HerokuError is raised before any HTTP request is made. LiteLLM would otherwise append /v1/chat/completions to the base.","triggerScenarios":"litellm.completion(model='heroku/<model>', ...) invoked without api_base=... and without HEROKU_API_BASE set in the process environment. Also triggered when the env var is set in a .env file that the running process never loaded.","commonSituations":"First-time Heroku Inference AI setup where the deployed endpoint URL was never configured; a typo'd env var name (e.g. HEROKU_API_URL); passing api_key but forgetting api_base; deploying to a container/platform where the env var did not propagate.","solutions":["Pass the endpoint explicitly: litellm.completion(model='heroku/<model>', api_base='https://<your-app>.herokuapp.com', api_key=...)","Or export HEROKU_API_BASE=https://<your-app>.herokuapp.com and verify the running process sees it (printenv HEROKU_API_BASE)","Do not append /v1/chat/completions yourself — LiteLLM adds it if the base does not already end with it","Smoke-test the base URL with curl <api_base>/v1/models to confirm it is live"],"exampleFix":"# before\nlitellm.completion(model=\"heroku/meta-llama/Llama-4-Scout-17B-16E-Instruct\", messages=msgs)\n\n# after\nlitellm.completion(\n    model=\"heroku/meta-llama/Llama-4-Scout-17B-16E-Instruct\",\n    api_base=\"https://your-inference-app.herokuapp.com\",\n    api_key=os.environ[\"HEROKU_API_KEY\"],\n    messages=msgs,\n)","handlingStrategy":"validation","validationCode":"import os\n\ndef heroku_ready(api_base: str | None = None) -> bool:\n    return bool(api_base or os.getenv(\"HEROKU_API_BASE\"))\n\nif not heroku_ready(api_base):\n    raise SystemExit(\"Set HEROKU_API_BASE or pass api_base before calling heroku models\")","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Centralize provider config: resolve api_base + api_key once at startup and fail fast if missing","Add a startup check for HEROKU_API_BASE in deployed environments (container, CI) where .env files are easy to miss","Use a thin wrapper around litellm.completion that injects api_base for heroku/* models so callers cannot forget it"],"tags":["heroku","api-base","configuration","missing-env-var","litellm"],"backgroundTag":"missing-api-base","analyzedSha":"77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8","analyzedAt":"2026-08-18T11:44:31.656Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}