Skip to main content
POST /v1/rerank Send JSON with model, a nonempty query, and candidate documents. Explicitly set top_n and return_documents and consult the guide for channel differences; unchanged forwarding is not guaranteed. results[].index points to the original input array, and relevance_score is a model-dependent ranking score. The shape and availability of document and usage depend on the channel. Allow extra fields and do not depend on returned source text. This endpoint only ranks supplied candidates; it does not generate vectors or answers. Guide and runnable example 简体中文

Authorizations

Authorization
string
header
required

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

Body

application/json
model
string
required

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

Example:

"YOUR_MODEL_ID"

query
string
required

非空查询文本 / Nonempty query text

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

非空候选列表;优先字符串,对象字段由渠道决定 / 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

Required range: 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

Response

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

results
object[]
required

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

usage
object