协议与接口
Rerank
用 POST /v1/rerank 对检索召回的候选内容按相关性重新排序。
首版设计
网关正在开发中,以下为首版接口设计。
向量检索召回的结果不一定按相关性排好。把用户问题和候选文本交给重排序模型,它会给每条候选打分并重新排序,RAG 回答会更准确。
curl https://api.example.cn/v1/rerank \
-H "Authorization: Bearer $RELAY_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "qwen3.7-text-rerank",
"query": "怎么开发票",
"documents": ["充值到账规则", "发票申请流程", "退款说明"],
"top_n": 2
}'{
"model": "qwen3.7-text-rerank",
"results": [
{ "index": 1, "relevance_score": 0.93 },
{ "index": 2, "relevance_score": 0.21 }
],
"usage": { "total_tokens": 38 }
}参数
| 参数 | 说明 |
|---|---|
model | 必填,重排序模型 ID |
query | 必填,用户问题 |
documents | 必填,候选文本数组 |
top_n | 只返回得分最高的前 N 条 |
return_documents | 是否在结果中带回原文,默认不带 |
index 对应 documents 里的位置,relevance_score 越高越相关。请求格式与常见的 Rerank 接口(如 Cohere、Jina)一致。
计费
按输入 tokens(查询与全部候选文本合计)计费,没有输出费用。
可用模型
| 模型 ID | 类型 | 输入 / 1M | 输出 / 1M | 上下文 | 线路 |
|---|---|---|---|---|---|
| qwen3.7-text-rerank | 重排序 | ¥0.50 | — | — | 阿里云百炼 |
| qwen3-vl-rerank | 重排序 | ¥0.50 起 | — 起 | — | 阿里云百炼 |