Rerank documents
const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({query: '<string>', documents: ['<string>']})
};
fetch('https://www.ninjachat.ai/api/v1/rerank', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));import requests
url = "https://www.ninjachat.ai/api/v1/rerank"
payload = {
"query": "<string>",
"documents": ["<string>"]
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)curl --request POST \
--url https://www.ninjachat.ai/api/v1/rerank \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"query": "<string>",
"documents": [
"<string>"
]
}
'{
"model": "<string>",
"provider": "<string>",
"results": [
{
"index": 1,
"relevance_score": 123,
"document": {
"text": "<string>"
}
}
],
"usage": {
"total_tokens": 1
},
"cost_usd": 1,
"request_id": "<string>"
}{
"error": {
"message": "<string>",
"type": "<string>",
"code": "<string>",
"param": "<string>"
}
}{
"error": {
"message": "<string>",
"type": "<string>",
"code": "<string>",
"param": "<string>"
}
}{
"error": {
"message": "<string>",
"type": "<string>",
"code": "<string>",
"param": "<string>"
}
}{
"error": {
"message": "<string>",
"type": "<string>",
"code": "<string>",
"param": "<string>"
}
}{
"error": {
"message": "<string>",
"type": "<string>",
"code": "<string>",
"param": "<string>"
}
}Media & search
Rerank documents
POST
/
rerank
Rerank documents
const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({query: '<string>', documents: ['<string>']})
};
fetch('https://www.ninjachat.ai/api/v1/rerank', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));import requests
url = "https://www.ninjachat.ai/api/v1/rerank"
payload = {
"query": "<string>",
"documents": ["<string>"]
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)curl --request POST \
--url https://www.ninjachat.ai/api/v1/rerank \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"query": "<string>",
"documents": [
"<string>"
]
}
'{
"model": "<string>",
"provider": "<string>",
"results": [
{
"index": 1,
"relevance_score": 123,
"document": {
"text": "<string>"
}
}
],
"usage": {
"total_tokens": 1
},
"cost_usd": 1,
"request_id": "<string>"
}{
"error": {
"message": "<string>",
"type": "<string>",
"code": "<string>",
"param": "<string>"
}
}{
"error": {
"message": "<string>",
"type": "<string>",
"code": "<string>",
"param": "<string>"
}
}{
"error": {
"message": "<string>",
"type": "<string>",
"code": "<string>",
"param": "<string>"
}
}{
"error": {
"message": "<string>",
"type": "<string>",
"code": "<string>",
"param": "<string>"
}
}{
"error": {
"message": "<string>",
"type": "<string>",
"code": "<string>",
"param": "<string>"
}
}Authorizations
Use an API key created in the NinjaChat developer console.
Headers
Safely retry the same logical write without duplicate billing or execution.
Required string length:
1 - 255Body
application/json