> ## Documentation Index
> Fetch the complete documentation index at: https://mixroute.ai/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Rerank v5.0 Pro

> Cohere 注重排序质量的多语言重排序模型，适合复杂查询和长文档，包含 MixRoute 请求示例和响应字段说明。

Rerank v5.0 Pro 按文档与查询的相关性重新排序。适用于重视检索质量的复杂查询，在将候选片段交给 LLM 前筛选相关内容。

先检索候选文档，再进行重排序。响应包含相关性分数和原始文档索引，不生成回答或向量。在 MixRoute 上使用 `/v1/rerank`。

## 模型信息

| 字段 | 说明 |
| - | - |
| `model` | rerank-v5.0-pro |
| `endpoint` | [POST /v1/rerank](https://mixroute.ai/docs/zh-Hans/api-reference/endpoint/rerank.md) |
| `context` | 32,768 tokens |

厂商上下文窗口为每组查询与文档合计 32,768 tokens，不是整个文档列表共用的上限。实际请求限制取决于 MixRoute 路由。

## 请求字段

| 字段 | 说明 |
| - | - |
| `model` | 必填，使用上方列出的完整模型 ID。 |
| `query` | 必填的查询字符串。 |
| `documents` | 必填的文档字符串数组。保留原始数组，以便通过索引对应结果。 |
| `top_n` | 可选的正整数，返回数量不超过候选文档数。 |
| `return_documents` | 可选布尔值。设为 true 时，在 `results[].document.text` 中返回原文。 |

## 请求示例

设置 `MIXROUTE_API_KEY` 环境变量。Python 示例使用 requests 包。

> [tab] cURL
>
> ```bash theme={null}
> curl --request POST "https://api.mixroute.ai/v1/rerank" \
>   --header "Authorization: Bearer $MIXROUTE_API_KEY" \
>   --header "Content-Type: application/json" \
>   --data '{
>   "model": "rerank-v5.0-pro",
>   "query": "What is the capital of France?",
>   "documents": [
>     "Paris is the capital of France.",
>     "A triangle has three sides."
>   ],
>   "top_n": 1,
>   "return_documents": true
> }'
> ```

> [tab] Python
>
> ```python theme={null}
> import os
> import requests
>
> documents = ["Paris is the capital of France.", "A triangle has three sides."]
> response = requests.post(
>     "https://api.mixroute.ai/v1/rerank",
>     headers={"Authorization": "Bearer " + os.environ["MIXROUTE_API_KEY"]},
>     json={
>         "model": "rerank-v5.0-pro",
>         "query": "What is the capital of France?",
>         "documents": documents,
>         "top_n": 1,
>         "return_documents": True,
>     },
>     timeout=60,
>     allow_redirects=False,
> )
> response.raise_for_status()
> result = response.json()
> if "error" in result:
>     raise RuntimeError(result["error"])
> for item in result["results"]:
>     print(item["relevance_score"], documents[item["index"]])
> print(result.get("usage", {}))
> ```

## 响应字段

`results[].index` 是文档在原始 documents 数组中的索引，从 0 开始。`results[].relevance_score` 是相关性分数，数值越大表示越相关。仅在响应包含文档原文时读取 `results[].document.text`。

```json theme={null}
{
  "results": [
    {
      "document": {
        "text": "Paris is the capital of France."
      },
      "index": 0,
      "relevance_score": 0.8398325
    }
  ],
  "usage": {
    "prompt_tokens": 27,
    "completion_tokens": 0,
    "total_tokens": 27
  }
}
```

## 用量与计费

通过 `usage.prompt_tokens` 和 `usage.total_tokens` 读取报告的 token 用量。重排序不生成回答文本，因此 `usage.completion_tokens` 可以为 0。其他通用 token 字段不能替代这两个用量字段。

当前价格和可用路由请查看[模型广场](https://console.mixroute.ai/models)。控制台消费日志显示每个请求的实际费用；核对账单时应使用这些记录，不要把 usage 对象当作美元金额。

[完整请求格式](https://mixroute.ai/docs/zh-Hans/api-reference/endpoint/rerank.md)。


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.