Skip to main content
POST /v1/rerank 发送 JSON,提供 model、非空 query 和候选 documents。建议显式设置 top_n、return_documents,并查看指南中的渠道差异;这些参数不保证原样转发。 results[].index 指向原输入数组位置,relevance_score 是模型相关的排序分数。document 和 usage 的实际形状与可用性依赖渠道,客户端允许额外字段,且不能依赖回传原文。此接口只排序传入候选,不生成向量或回答。 完整指南与可运行示例 Read in English

授权

Authorization
string
header
必填

模型调用 API Key,不是控制台登录凭据 / Model API key, not console login credentials

请求体

application/json
model
string
必填

支持此接口且当前密钥可用的模型 / Model available to this key and supporting this endpoint

示例:

"YOUR_MODEL_ID"

query
string
必填

非空查询文本 / Nonempty query text

Minimum string length: 1
documents
(string | object)[]
必填

非空候选列表;优先字符串,对象字段由渠道决定 / Nonempty candidates; prefer strings, object fields depend on channel

Minimum array length: 1
Minimum string length: 1
top_n
integer

建议正整数且不超过候选数;Cohere 省略或非正数时转为 1,其他渠道默认不同 / Use a positive count no larger than candidates; Cohere maps omitted/nonpositive to 1, other defaults differ

必填范围: x >= 1
return_documents
boolean

请求回传原文;Cohere 强制 true,Ali 省略时默认 true;不能作为通用不回传保证 / Request source text; Cohere forces true, Ali defaults to true when omitted; not a universal suppression guarantee

max_chunk_per_doc
integer

可选渠道参数;注意单数拼写,部分适配器不转发 / Optional channel parameter; singular spelling, not forwarded by all adaptors

overlap_tokens
integer

可选分块重叠参数;支持情况由渠道决定 / Optional chunk overlap; support depends on channel

响应

成功结构;仍需校验索引与实际数值,示例向量维度和分数仅作结构演示 / Success shape; validate indices and values; example vector dimensions and scores are illustrative

results
object[]
必填

候选的相关性结果;可为空 / Candidate relevance results; may be empty

usage
object