← Docs
Rerank
Rank candidate documents against a query for RAG, enterprise search, and retrieval refinement.
Request example
cURL
curl https://test.sealink.io/v1/rerank \-H "Authorization: Bearer <your-sealink-key>" \-H "Content-Type: application/json" \-d '{"model": "qwen3-rerank","query": "best API gateway for Qwen models","documents": ["SeaLink exposes one rerank API with customer-visible model IDs.","A sourdough starter needs regular feeding.","Rerank models improve retrieval quality for RAG."],"top_n": 2}'
Python
import requestsurl = "https://test.sealink.io/v1/rerank"headers = {"Authorization": f"Bearer {api_key}"}payload = {"model": "qwen3-rerank","query": "best API gateway for Qwen models","documents": ["SeaLink exposes one rerank API with customer-visible model IDs.","A sourdough starter needs regular feeding.","Rerank models improve retrieval quality for RAG.",],"top_n": 2,}resp = requests.post(url, json=payload, headers=headers)data = resp.json()for r in data["results"]:print(f"doc[{r['index']}] score={r['relevance_score']:.4f}")
Node.js
const resp = await fetch("https://test.sealink.io/v1/rerank", {method: "POST",headers: {"Authorization": `Bearer ${process.env.SEALINK_API_KEY}`,"Content-Type": "application/json",},body: JSON.stringify({model: "qwen3-rerank",query: "best API gateway for Qwen models",documents: ["SeaLink exposes one rerank API with customer-visible model IDs.","A sourdough starter needs regular feeding.","Rerank models improve retrieval quality for RAG.",],top_n: 2,}),});const data = await resp.json();data.results.forEach(r => console.log(`doc[${r.index}] score=${r.relevance_score.toFixed(4)}`));
Parameters
| Field | Type | Description |
|---|---|---|
| model | string | qwen3-rerank |
| query | string | Query to rank documents against |
| documents | string[] | Candidate document array |
| top_n | integer | Return the top N results; omit to return all |
Response
Returns a results array with the original index, relevance score, and document text.
Response example
{"id": "rerank-b1a2c3d4","model": "qwen3-rerank","results": [{"index": 2,"document": {"text": "Rerank models improve retrieval quality for RAG."},"relevance_score": 0.95},{"index": 0,"document": {"text": "SeaLink exposes one rerank API with customer-visible model IDs."},"relevance_score": 0.82}]}