{"record":{"id":"4086ba7786322798","repo":"BerriAI/litellm","slug":"api-base-is-required-for-hosted-vllm-embeddings","errorCode":null,"errorMessage":"api_base is required for hosted_vllm embeddings","messagePattern":"api_base is required for hosted_vllm embeddings","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"litellm/llms/hosted_vllm/embedding/transformation.py","lineNumber":82,"sourceCode":"        # Merge with existing headers (user's headers take priority)\n        return {**default_headers, **headers}\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        \"\"\"\n        Get the complete URL for Hosted VLLM Embedding API endpoint.\n        \"\"\"\n        if api_base is None:\n            api_base = get_secret_str(\"HOSTED_VLLM_API_BASE\")\n            if api_base is None:\n                raise ValueError(\"api_base is required for hosted_vllm embeddings\")\n\n        # Remove trailing slashes\n        api_base = api_base.rstrip(\"/\")\n\n        # Ensure the URL ends with /embeddings\n        if not api_base.endswith(\"/embeddings\"):\n            api_base = f\"{api_base}/embeddings\"\n\n        return api_base\n\n    def transform_embedding_request(\n        self,\n        model: str,\n        input: AllEmbeddingInputValues,\n        optional_params: dict,\n        headers: dict,\n    ) -> dict:\n        \"\"\"","sourceCodeStart":64,"sourceCodeEnd":100,"githubUrl":"https://github.com/BerriAI/litellm/blob/77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8/litellm/llms/hosted_vllm/embedding/transformation.py#L64-L100","documentation":"The HostedVLLM embedding handler's get_complete_url() builds the endpoint from an explicit api_base argument or the HOSTED_VLLM_API_BASE environment variable. Unlike cloud providers, self-hosted vLLM has no default hostname, so if neither is set a ValueError is raised before the request is sent. The final URL gets /embeddings appended if missing.","triggerScenarios":"litellm.embedding(model='hosted_vllm/<embedding-model>', input=[...]) called without api_base and without HOSTED_VLLM_API_BASE in the environment.","commonSituations":"Running embeddings against a local/remote vLLM server and forgetting the base URL; setting VLLM_API_BASE instead of HOSTED_VLLM_API_BASE; .env file not loaded in the deployed process; reusing config from a different provider that has a default base.","solutions":["Pass api_base explicitly: litellm.embedding(model='hosted_vllm/<model>', api_base='http://localhost:8001', input=[...])","Or export HOSTED_VLLM_API_BASE=http://localhost:8001 (note the HOSTED_ prefix — VLLM_API_BASE is a different variable)","Point it at the server that actually serves /embeddings (a vLLM instance started with an embedding model), not the chat server","Do not append /embeddings yourself; LiteLLM appends it if missing"],"exampleFix":"# before\nlitellm.embedding(model=\"hosted_vllm/BAAI/bge-m3\", input=[\"hello\"])\n\n# after\nlitellm.embedding(\n    model=\"hosted_vllm/BAAI/bge-m3\",\n    api_base=\"http://localhost:8001\",\n    input=[\"hello\"],\n)","handlingStrategy":"validation","validationCode":"import os\n\nVLLM_EMBED_BASE = api_base or os.getenv(\"HOSTED_VLLM_API_BASE\")\nif not VLLM_EMBED_BASE:\n    raise SystemExit(\"hosted_vllm embeddings need api_base or HOSTED_VLLM_API_BASE\")","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Keep chat server and embedding server bases in separate, explicitly named config keys","Remember the env var is HOSTED_VLLM_API_BASE, not VLLM_API_BASE","Smoke-test <base>/embeddings with curl when provisioning a new embedding server"],"tags":["hosted-vllm","embeddings","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"}