Text Series
Document Reranking
Rerank documents by relevance for RAG
POST
Document Reranking
The Rerank API reorders documents by relevance to a query, improving retrieval quality in RAG (Retrieval-Augmented Generation) pipelines.Endpoint
Authentication
Request Body
| Parameter | Type | Required | Description |
|---|---|---|---|
model | string | Yes | Reranking model ID |
query | string | Yes | Search query |
documents | array | Yes | Documents to rerank |
top_n | integer | No | Number of top results to return |
return_documents | boolean | No | Include document text in response |
Document Format
Documents can be strings or objects:Example Request
RAG Pipeline Integration
Step 1: Initial Retrieval
Step 2: Rerank
Step 3: Generate Response
With Document IDs
Track documents through the reranking process:Supported Models
| Model | Description |
|---|---|
rerank-v3 | Latest high-accuracy reranker |
rerank-v2 | Balanced speed and accuracy |
rerank-lite | Fast, cost-effective option |
Best Practices
- Over-fetch then rerank: Retrieve more candidates (20-100) then rerank to top 3-10
- Keep documents concise: Chunk long documents before reranking
- Combine with embeddings: Use embeddings for initial retrieval, rerank for precision
- Batch appropriately: Send related documents together for consistent scoring