{"record":{"id":"1ac212e47ca5868b","repo":"BerriAI/litellm","slug":"query-is-required-for-nvidia-nim-rerank","errorCode":null,"errorMessage":"query is required for Nvidia NIM rerank","messagePattern":"query is required for Nvidia NIM rerank","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"litellm/llms/nvidia_nim/rerank/transformation.py","lineNumber":198,"sourceCode":"        model: str,\n        optional_rerank_params: dict,\n        headers: dict,\n        litellm_params: dict | None = None,\n    ) -> dict:\n        \"\"\"\n        Transform request to Nvidia NIM format.\n\n        Nvidia NIM expects:\n        - query as {text: \"...\"}\n        - documents as passages: [{text: \"...\"}, ...]\n        - Optional: truncate (NONE or END), top_k\n\n        Note: optional_rerank_params may contain provider-specific params like 'top_k' and 'truncate'\n        that aren't in the OptionalRerankParams TypedDict but are passed through at runtime.\n        The mapping from Cohere's 'top_n' to Nvidia's 'top_k' already happened in map_cohere_rerank_params.\n        \"\"\"\n        if \"query\" not in optional_rerank_params:\n            raise ValueError(\"query is required for Nvidia NIM rerank\")\n        if \"documents\" not in optional_rerank_params:\n            raise ValueError(\"documents is required for Nvidia NIM rerank\")\n\n        query: Final = optional_rerank_params[\"query\"]\n        documents: Final = optional_rerank_params[\"documents\"]\n\n        # Transform query to object format\n        query_obj: Final[NvidiaNimQueryObject] = {\"text\": query}\n\n        # Transform documents to passages format\n        passages: Final[list[NvidiaNimPassageObject]] = []\n        for doc in documents:\n            if isinstance(doc, str):\n                passages.append({\"text\": doc})\n            elif isinstance(doc, dict):\n                # Preserve only the structured passage fields supported by the\n                # selected rerank route.\n                supported_fields: NvidiaNimPassageObject = {}  # mutable-ok: assembling a request TypedDict","sourceCodeStart":180,"sourceCodeEnd":216,"githubUrl":"https://github.com/BerriAI/litellm/blob/77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8/litellm/llms/nvidia_nim/rerank/transformation.py#L180-L216","documentation":"Error \"query is required for Nvidia NIM rerank\" thrown in BerriAI/litellm.","triggerScenarios":"Thrown at litellm/llms/nvidia_nim/rerank/transformation.py:198 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Provide the query argument to the Nvidia NIM rerank call."],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8","analyzedAt":"2026-08-18T11:44:31.656Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}