Rerank
POST /v1/rerank
Reorder documents by relevance to a query using cross-encoder models, improving retrieval accuracy in RAG pipelines.
Request
POST https://api.chuizi.ai/v1/rerank
Authentication
Authorization: Bearer ck-your-api-key
Parameters
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
model | string | Yes | — | Model name, e.g. cohere/rerank-v3.5, jina/jina-reranker-v2 |
query | string | Yes | — | The search query to rank documents against |
documents | string[] | Yes | — | Array of document strings to rerank |
Request Example
config.json
json
{ "model": "cohere/rerank-v3.5", "query": "What is the capital of France?", "documents": [ "Paris is the capital and largest city of France.", "Berlin is the capital of Germany.", "The Eiffel Tower is located in Paris, France.", "London is the capital of the United Kingdom." ], "top_n": 3, "return_documents": true }
Response
config.json
json
{ "id": "gen-xxxxxxxxxxxxxxxx", "model": "cohere/rerank-v3.5", "results": [ { "index": 0, "relevance_score": 0.9985, "document": { "text": "Paris is the capital and largest city of France." } }, { "index": 2, "relevance_score": 0.8721, "document": { "text": "The Eiffel Tower is located in Paris, France." } }, { "index": 3, "relevance_score": 0.1503, "document": { "text": "London is the capital of the United Kingdom." } } ], "usage": { "total_tokens": 82 } }
Code Examples
terminal
bash
curl -X POST https://api.chuizi.ai/v1/rerank \ -H "Authorization: Bearer ck-your-key" \ -H "Content-Type: application/json" \ -d '{ "model": "cohere/rerank-v3.5", "query": "What is the capital of France?", "documents": [ "Paris is the capital and largest city of France.", "Berlin is the capital of Germany." ], "top_n": 2 }'
Next Steps
- Embeddings API — generate vector embeddings for semantic search
- Choose a Model — compare reranking model options
- Pricing — reranking model costs