Rerank
POST
/v1/rerank根据查询对候选文档重新排序。
结果结构和相关性分数由所选模型 Provider 返回。本文档不假设固定分数范围或批量上限。
核心请求字段
| 字段 | 类型 | 必填 | 说明 |
|---|---|---|---|
model | string | 是 | Rerank 模型 ID。 |
query | string | 是 | 用于相关性排序的查询文本。 |
documents | array | 是 | 需要排序的候选文档。 |
top_n | integer | 否 | 期望返回的结果数量,仅在模型支持时使用。 |
请求示例
curl
curl https://api.noxgate.net/v1/rerank \
-H "Authorization: Bearer sk-your-api-key" \
-H "Content-Type: application/json" \
-d '{"model":"YOUR_MODEL_ID","query":"What is NoxGate?","documents":["An AI API gateway","A weather report"],"top_n":2}'Python · requests
import requests
response = requests.post(
"https://api.noxgate.net/v1/rerank",
headers={"Authorization": "Bearer sk-your-api-key"},
json={"model": "YOUR_MODEL_ID", "query": "What is NoxGate?", "documents": ["An AI API gateway", "A weather report"]},
)
print(response.json())Node.js · fetch
const response = await fetch("https://api.noxgate.net/v1/rerank", {
method: "POST",
headers: { Authorization: "Bearer sk-your-api-key", "Content-Type": "application/json" },
body: JSON.stringify({ model: "YOUR_MODEL_ID", query: "What is NoxGate?", documents: ["An AI API gateway", "A weather report"] }),
});
console.log(await response.json());成功响应
JSON
{"id":"rerank_example","results":[{"index":0,"relevance_score":0.97},{"index":1,"relevance_score":0.08}],"usage":{"total_tokens":18}}