{"record":{"id":"bb37276cf7b6aa22","repo":"BerriAI/litellm","slug":"api-base-is-required-bb3727","errorCode":null,"errorMessage":"api_base is required","messagePattern":"api_base is required","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"litellm/llms/base_llm/responses/transformation.py","lineNumber":116,"sourceCode":"    @abstractmethod\n    def validate_environment(self, headers: dict, model: str, litellm_params: GenericLiteLLMParams | None) -> dict:\n        return {}\n\n    @abstractmethod\n    def get_complete_url(\n        self,\n        api_base: str | None,\n        litellm_params: dict,\n    ) -> str:\n        \"\"\"\n        OPTIONAL\n\n        Get the complete url for the request\n\n        Some providers need `model` in `api_base`\n        \"\"\"\n        if api_base is None:\n            raise ValueError(\"api_base is required\")\n        return api_base\n\n    @abstractmethod\n    def transform_responses_api_request(\n        self,\n        model: str,\n        input: str | ResponseInputParam,\n        response_api_optional_request_params: dict,\n        litellm_params: GenericLiteLLMParams,\n        headers: dict,\n    ) -> dict:\n        pass\n\n    @abstractmethod\n    def transform_response_api_response(\n        self,\n        model: str,\n        raw_response: httpx.Response,","sourceCodeStart":98,"sourceCodeEnd":134,"githubUrl":"https://github.com/BerriAI/litellm/blob/6c2dcb801bf2b75c18f1bb24140e7cf57465cc4d/litellm/llms/base_llm/responses/transformation.py#L98-L134","documentation":"Base Responses-API transformation raises ValueError when get_complete_url receives api_base=None. The Responses API (/v1/responses) needs a concrete host; the default implementation returns api_base unchanged, so a missing value is rejected immediately rather than producing a broken request URL.","triggerScenarios":"Calling litellm.responses(...) for a provider with no resolvable base URL: custom_llm_provider without <PROVIDER>_API_BASE set, proxy model entry missing api_base, or a self-hosted endpoint configured only via env var that is absent in the runtime.","commonSituations":"Switching from chat completions (which had defaults) to the newer Responses API for a custom provider; env var naming mismatches (OPENAI_API_BASE vs OPENAI_BASE_URL); containerized deploys dropping env configuration.","solutions":["Pass api_base in the call: litellm.responses(model=..., input=..., api_base='https://host').","Set the provider base URL env var (OPENAI_API_BASE or <PROVIDER>_API_BASE).","Add api_base to the proxy model's litellm_params in config.yaml.","Provider config authors: override get_complete_url with the provider's responses endpoint default."],"exampleFix":"# before\nlitellm.responses(model='openai/gpt-4o', input='hi')  # no base URL configured\n\n# after\nlitellm.responses(model='openai/gpt-4o', input='hi', api_base='https://api.openai.com/v1')","handlingStrategy":"validation","validationCode":"def assert_responses_ready(api_base: str | None) -> None:\n    if not api_base and not os.environ.get('OPENAI_API_BASE'):\n        raise ConfigError('responses API requires api_base')","typeGuard":null,"tryCatchPattern":"try:\n    litellm.responses(model=m, input=i)\nexcept ValueError as e:\n    if 'api_base is required' in str(e):\n        return litellm.responses(model=m, input=i, api_base=DEFAULT_BASE_URL)\n    raise","preventionTips":["Pass api_base explicitly for every non-default provider call.","Load and validate all provider env vars in one settings module at boot.","Add config schema validation (pydantic) so missing base URLs fail at deploy, not at request time."],"tags":["responses-api","api-base","configuration","url-construction"],"backgroundTag":null,"analyzedSha":"6c2dcb801bf2b75c18f1bb24140e7cf57465cc4d","analyzedAt":"2026-08-15T07:12:03.035Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}