Rerank documents by relevance to a query
POST
/v1/rerankPOST
/v1/rerankYour instance endpoint, shown on the instance page in the dashboard. Each instance has its own host; there is no shared API host.
Request Body
| Property | Type | Required | Description |
|---|---|---|---|
model | string | No | |
query | string | No | |
documents | string[] | No | |
documentObjects | object[] | No | |
topN | integer | No | |
returnDocuments | boolean | No | |
maxTokensPerDoc | integer | No | |
metadata | object | No |
Responses
200 Reranked documents
| Property | Type | Description |
|---|---|---|
id | string | |
model | string | |
results | object[] | |
meta | object |
default An unexpected error response.
| Property | Type | Description |
|---|---|---|
code | integer | |
message | string | |
details | object[] |
Request
curl -X POST "http://localhost:8089/v1/rerank" \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{"model":"string","query":"string","documents":["string"],"documentObjects":[{"text":"string"}],"topN":0,"returnDocuments":true,"maxTokensPerDoc":0}'const response = await fetch("http://localhost:8089/v1/rerank", {
method: "POST",
headers: {
"Authorization": "Bearer YOUR_API_KEY",
"Content-Type": "application/json",
},
body: JSON.stringify({
"model": "string",
"query": "string",
"documents": [
"string"
],
"documentObjects": [
{
"text": "string"
}
],
"topN": 0,
"returnDocuments": true,
"maxTokensPerDoc": 0
}),
});
const data = await response.json();import requests
response = requests.post(
"http://localhost:8089/v1/rerank",
headers={
"Authorization": "Bearer YOUR_API_KEY",
"Content-Type": "application/json",
},
json={
"model": "string",
"query": "string",
"documents": [
"string"
],
"documentObjects": [
{
"text": "string"
}
],
"topN": 0,
"returnDocuments": true,
"maxTokensPerDoc": 0
},
)
data = response.json()Response
{
"id": "string",
"model": "string",
"results": [
{
"index": 0,
"relevanceScore": 0,
"document": "string"
}
],
"meta": {
"version": "string",
"isBillable": true,
"billedUnits": {
"searchUnits": 0,
"inputTokens": 0,
"outputTokens": 0
},
"tokens": {
"inputTokens": 0,
"outputTokens": 0
}
}
}{
"code": 0,
"message": "string",
"details": [
{
"@type": "string"
}
]
}
