POST
/
v1
/
rerank
curl -X POST "https://api.applerouter.ai/v1/rerank" \
  -H "Authorization: Bearer sk-your-api-key" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "rerank-english-v2.0",
    "query": "What is machine learning?",
    "documents": [
      "Machine learning is a subset of artificial intelligence.",
      "The weather today is sunny.",
      "Deep learning uses neural networks.",
      "I like to eat pizza."
    ],
    "top_n": 2,
    "return_documents": true
  }'
{
  "id": "rerank-abc123",
  "results": [
    {
      "index": 0,
      "relevance_score": 0.9876,
      "document": {
        "text": "Machine learning is a subset of artificial intelligence."
      }
    },
    {
      "index": 2,
      "relevance_score": 0.8543,
      "document": {
        "text": "Deep learning uses neural networks."
      }
    }
  ],
  "meta": {}
}

Overview

Rerank a list of documents based on their relevance to a query. Used to improve search results and RAG flows.
model
string
required
Rerank Model ID (e.g. rerank-english-v2.0, rerank-multilingual-v2.0)
query
string
required
Search Query
documents
array
required
List of documents to rerank (strings or objects)
top_n
integer
Return only top N results
return_documents
boolean
Include document content in response (default: false)
curl -X POST "https://api.applerouter.ai/v1/rerank" \
  -H "Authorization: Bearer sk-your-api-key" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "rerank-english-v2.0",
    "query": "What is machine learning?",
    "documents": [
      "Machine learning is a subset of artificial intelligence.",
      "The weather today is sunny.",
      "Deep learning uses neural networks.",
      "I like to eat pizza."
    ],
    "top_n": 2,
    "return_documents": true
  }'
{
  "id": "rerank-abc123",
  "results": [
    {
      "index": 0,
      "relevance_score": 0.9876,
      "document": {
        "text": "Machine learning is a subset of artificial intelligence."
      }
    },
    {
      "index": 2,
      "relevance_score": 0.8543,
      "document": {
        "text": "Deep learning uses neural networks."
      }
    }
  ],
  "meta": {}
}

Use Cases

  • Search Ranking: Improve sorting of search results
  • RAG Flows: Rerank retrieved documents before passing to LLM
  • Document Filtering: Find most relevant documents for a topic

Authorizations

Authorization
string
header
required

使用 Bearer Token 认证。格式: Authorization: Bearer sk-xxxxxx

Body

application/json
model
string
required
Example:

"rerank-english-v2.0"

query
string
required

查询文本

documents
(string | object)[]
required

要重排序的文档列表

top_n
integer

返回前 N 个结果

return_documents
boolean
default:false

Response

200 - application/json

成功重排序

id
string
results
object[]
meta
object