{"record":{"id":"1177b6f9d5296b10","repo":"BerriAI/litellm","slug":"query-is-required-for-hosted-vllm-rerank","errorCode":null,"errorMessage":"query is required for Hosted VLLM rerank","messagePattern":"query is required for Hosted VLLM rerank","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"litellm/llms/hosted_vllm/rerank/transformation.py","lineNumber":135,"sourceCode":"            \"content-type\": \"application/json\",\n        }\n\n        # If 'Authorization' is provided in headers, it overrides the default.\n        if \"Authorization\" in headers:\n            default_headers[\"Authorization\"] = headers[\"Authorization\"]\n\n        # Merge other headers, overriding any default ones except Authorization\n        return {**default_headers, **headers}\n\n    def transform_rerank_request(\n        self,\n        model: str,\n        optional_rerank_params: dict,\n        headers: dict,\n        litellm_params: dict | None = None,\n    ) -> dict:\n        if \"query\" not in optional_rerank_params:\n            raise ValueError(\"query is required for Hosted VLLM rerank\")\n        if \"documents\" not in optional_rerank_params:\n            raise ValueError(\"documents is required for Hosted VLLM rerank\")\n\n        rerank_request: Final = RerankRequest(\n            model=model,\n            query=optional_rerank_params[\"query\"],\n            documents=optional_rerank_params[\"documents\"],\n            top_n=optional_rerank_params.get(\"top_n\", None),\n            rank_fields=optional_rerank_params.get(\"rank_fields\", None),\n            return_documents=optional_rerank_params.get(\"return_documents\", None),\n            instruction=optional_rerank_params.get(\"instruction\", None),\n        )\n        return rerank_request.model_dump(exclude_none=True)\n\n    def transform_rerank_response(\n        self,\n        model: str,\n        raw_response: httpx.Response,","sourceCodeStart":117,"sourceCodeEnd":153,"githubUrl":"https://github.com/BerriAI/litellm/blob/77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8/litellm/llms/hosted_vllm/rerank/transformation.py#L117-L153","documentation":"Before sending a rerank request to vLLM, transform_rerank_request() validates the Cohere-style payload and requires a top-level 'query' string. vLLM's /rerank endpoint (Jina-compatible) cannot rank without a query, so its absence raises ValueError before any network call. The same function also requires 'documents'.","triggerScenarios":"litellm.rerank(model='hosted_vllm/...', documents=[...]) with no query kwarg; building optional_rerank_params dynamically and the query key getting dropped; passing query=None explicitly (the key exists upstream but is stripped before this point).","commonSituations":"Typos in the kwarg name (q=, search_query=); refactoring from a provider whose API makes the query optional; a wrapper that filters out falsy values and removes query='' before delegating.","solutions":["Pass a non-empty query string: litellm.rerank(model=..., api_base=..., query='what is litellm', documents=[...])","If building params dynamically, assert 'query' in params before calling litellm.rerank","Check for upstream code that pops or filters the query key","Use litellm.validate_rerank_params or inspect RerankRequest fields if unsure of the expected shape"],"exampleFix":"# before\nlitellm.rerank(model=\"hosted_vllm/jina-reranker\", api_base=base, documents=[\"a\", \"b\"])\n\n# after\nlitellm.rerank(model=\"hosted_vllm/jina-reranker\", api_base=base, query=\"find a\", documents=[\"a\", \"b\"])","handlingStrategy":"validation","validationCode":"if not (query and query.strip()):\n    raise ValueError(\"rerank requires a non-empty query\")","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Treat query and documents as required positional data in your retrieval layer, not optional kwargs","Assert the presence of both keys in any wrapper that builds rerank params dynamically","Fail fast in retrieval pipelines when the query is empty instead of calling through"],"tags":["hosted-vllm","rerank","missing-argument","request-validation","litellm"],"backgroundTag":"missing-required-argument","analyzedSha":"77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8","analyzedAt":"2026-08-18T11:44:31.656Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}