{"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/77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8/litellm/llms/hosted_vllm/responses/transformation.py#L38-L74","documentation":"The hosted_vllm Responses API transformation requires an explicit base URL: get_complete_url() falls back to the HOSTED_VLLM_API_BASE environment variable and raises ValueError if both are unset. The URL is normalized (trailing slashes stripped; /responses appended to a base already ending in /v1, otherwise /v1/responses). As with all hosted_vllm routes, there is no default host because the server is user-deployed.","triggerScenarios":"litellm.responses(model='hosted_vllm/<model>', input=...) called without api_base and without HOSTED_VLLM_API_BASE in the environment.","commonSituations":"Trying LiteLLM's Responses API against a self-hosted vLLM instance and forgetting the base URL; env var present in dev but missing in CI/containers; pointing at a vLLM build that does not serve /v1/responses so other errors follow once the base is set.","solutions":["Pass api_base: litellm.responses(model='hosted_vllm/<model>', api_base='http://localhost:8000/v1', input=...)","Or export HOSTED_VLLM_API_BASE=http://localhost:8000 (add /v1 if your base includes it — the suffix logic adapts)","Confirm the vLLM server was built with the Responses API enabled and serves /v1/responses (curl it)","Prefer a base ending in /v1 so the /responses suffix is appended consistently"],"exampleFix":"# before\nlitellm.responses(model=\"hosted_vllm/Qwen/Qwen3-32B\", input=\"hello\")\n\n# after\nlitellm.responses(\n    model=\"hosted_vllm/Qwen/Qwen3-32B\",\n    api_base=\"http://localhost:8000/v1\",\n    input=\"hello\",\n)","handlingStrategy":"validation","validationCode":"import os\n\nbase = api_base or os.getenv(\"HOSTED_VLLM_API_BASE\")\nif not base:\n    raise SystemExit(\"hosted_vllm responses API needs api_base or HOSTED_VLLM_API_BASE\")","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Prefer a base ending in /v1 so /responses is appended consistently","Confirm the vLLM build actually serves /v1/responses before wiring Responses API calls","Smoke-test with curl after server upgrades — Responses API support in vLLM is version-dependent"],"tags":["hosted-vllm","responses-api","api-base","configuration","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"}