{"record":{"id":"291b3e75c959220f","repo":"BerriAI/litellm","slug":"api-base-not-set-for-hosted-vllm-responses-api-se","errorCode":null,"errorMessage":"api_base not set for Hosted VLLM responses API. Set via api_base parameter or HOSTED_VLLM_API_BASE environment variable","messagePattern":"api_base not set for Hosted VLLM responses API\\. Set via api_base parameter or HOSTED_VLLM_API_BASE environment variable","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"litellm/llms/hosted_vllm/responses/transformation.py","lineNumber":56,"sourceCode":"        api_key: Final = (\n            litellm_params.api_key or get_secret_str(\"HOSTED_VLLM_API_KEY\") or \"fake-api-key\"\n        )  # vllm does not require an api key\n        headers.update(\n            {\n                \"Authorization\": f\"Bearer {api_key}\",\n            }\n        )\n        return headers\n\n    def get_complete_url(\n        self,\n        api_base: str | None,\n        litellm_params: dict,\n    ) -> str:\n        api_base = api_base or get_secret_str(\"HOSTED_VLLM_API_BASE\")\n\n        if api_base is None:\n            raise ValueError(\n                \"api_base not set for Hosted VLLM responses API. \"\n                \"Set via api_base parameter or HOSTED_VLLM_API_BASE environment variable\"\n            )\n\n        # Remove trailing slashes\n        api_base = api_base.rstrip(\"/\")\n\n        # If api_base already ends with /v1, append /responses\n        # Otherwise append /v1/responses\n        if api_base.endswith(\"/v1\"):\n            return f\"{api_base}/responses\"\n\n        return f\"{api_base}/v1/responses\"\n\n    def supports_native_websocket(self) -> bool:\n        \"\"\"Hosted vLLM does not support native WebSocket for Responses API\"\"\"\n        return False\n","sourceCodeStart":38,"sourceCodeEnd":74,"githubUrl":"https://github.com/BerriAI/litellm/blob/6c2dcb801bf2b75c18f1bb24140e7cf57465cc4d/litellm/llms/hosted_vllm/responses/transformation.py#L38-L74","documentation":"Raised by HostedVLLM ResponsesAPIConfig.get_complete_url when neither the api_base argument nor the HOSTED_VLLM_API_BASE environment variable is set. The /v1/responses API handler (distinct from the chat/embedding handlers) needs your self-hosted vLLM server URL and fails fast with a ValueError describing both resolution routes.","triggerScenarios":"Calling litellm.responses(model='hosted_vllm/...', ...) with no api_base and no HOSTED_VLLM_API_BASE env var. Note this handler DOES honor the env var (unlike the rerank handler) — the error only fires when both sources are empty.","commonSituations":"Env var set in the chat service container but the responses call runs elsewhere (job/worker without the var); experimenting with the new Responses API on an existing hosted_vllm setup where api_base was always passed per-call before; typo in the env var name.","solutions":["Set export HOSTED_VLLM_API_BASE=http://vllm-host:8000 (the code appends /responses or /v1/responses depending on whether the base already ends with /v1).","Or pass api_base='http://vllm-host:8000' to the litellm.responses call.","Confirm your vLLM build actually serves the /v1/responses endpoint (recent vLLM versions only) before relying on this path."],"exampleFix":"# before\nlitellm.responses(model='hosted_vllm/qwen3-32b', input='hello')\n# raises ValueError: api_base not set for Hosted VLLM responses API\n\n# after\nlitellm.responses(\n    model='hosted_vllm/qwen3-32b',\n    input='hello',\n    api_base='http://localhost:8000',  # -> http://localhost:8000/v1/responses\n)\n","handlingStrategy":"validation","validationCode":"import os\n\ndef vllm_responses_base(api_base: str | None = None) -> str:\n    base = api_base or os.environ.get(\"HOSTED_VLLM_API_BASE\")\n    if not base:\n        raise ValueError(\"api_base or HOSTED_VLLM_API_BASE required for hosted_vllm responses API\")\n    return base","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Set HOSTED_VLLM_API_BASE in every container/job that calls hosted_vllm — this handler honors it, unlike rerank/transcriptions.","Verify the deployed vLLM build serves /v1/responses before wiring the responses API path."],"tags":["hosted-vllm","responses-api","api-base","configuration","env-vars"],"backgroundTag":null,"analyzedSha":"6c2dcb801bf2b75c18f1bb24140e7cf57465cc4d","analyzedAt":"2026-08-15T07:12:03.035Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}