Rerank
curl --request POST \
--url https://api.gravitex.ai/v1/rerank \
--header 'Authorization: <authorization>' \
--header 'Content-Type: application/json' \
--data '
{
"model": "<string>",
"query": "<string>",
"documents": [
{}
],
"top_n": 123,
"return_documents": true
}
'import requests
url = "https://api.gravitex.ai/v1/rerank"
payload = {
"model": "<string>",
"query": "<string>",
"documents": [{}],
"top_n": 123,
"return_documents": True
}
headers = {
"Authorization": "<authorization>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: '<authorization>', 'Content-Type': 'application/json'},
body: JSON.stringify({
model: '<string>',
query: '<string>',
documents: [{}],
top_n: 123,
return_documents: true
})
};
fetch('https://api.gravitex.ai/v1/rerank', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.gravitex.ai/v1/rerank",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'model' => '<string>',
'query' => '<string>',
'documents' => [
[
]
],
'top_n' => 123,
'return_documents' => true
]),
CURLOPT_HTTPHEADER => [
"Authorization: <authorization>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.gravitex.ai/v1/rerank"
payload := strings.NewReader("{\n \"model\": \"<string>\",\n \"query\": \"<string>\",\n \"documents\": [\n {}\n ],\n \"top_n\": 123,\n \"return_documents\": true\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "<authorization>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.gravitex.ai/v1/rerank")
.header("Authorization", "<authorization>")
.header("Content-Type", "application/json")
.body("{\n \"model\": \"<string>\",\n \"query\": \"<string>\",\n \"documents\": [\n {}\n ],\n \"top_n\": 123,\n \"return_documents\": true\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.gravitex.ai/v1/rerank")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = '<authorization>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"model\": \"<string>\",\n \"query\": \"<string>\",\n \"documents\": [\n {}\n ],\n \"top_n\": 123,\n \"return_documents\": true\n}"
response = http.request(request)
puts response.read_bodyCompletions & Embeddings
Rerank
Rerank documents by relevance to a query
POST
/
v1
/
rerank
Rerank
curl --request POST \
--url https://api.gravitex.ai/v1/rerank \
--header 'Authorization: <authorization>' \
--header 'Content-Type: application/json' \
--data '
{
"model": "<string>",
"query": "<string>",
"documents": [
{}
],
"top_n": 123,
"return_documents": true
}
'import requests
url = "https://api.gravitex.ai/v1/rerank"
payload = {
"model": "<string>",
"query": "<string>",
"documents": [{}],
"top_n": 123,
"return_documents": True
}
headers = {
"Authorization": "<authorization>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: '<authorization>', 'Content-Type': 'application/json'},
body: JSON.stringify({
model: '<string>',
query: '<string>',
documents: [{}],
top_n: 123,
return_documents: true
})
};
fetch('https://api.gravitex.ai/v1/rerank', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.gravitex.ai/v1/rerank",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'model' => '<string>',
'query' => '<string>',
'documents' => [
[
]
],
'top_n' => 123,
'return_documents' => true
]),
CURLOPT_HTTPHEADER => [
"Authorization: <authorization>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.gravitex.ai/v1/rerank"
payload := strings.NewReader("{\n \"model\": \"<string>\",\n \"query\": \"<string>\",\n \"documents\": [\n {}\n ],\n \"top_n\": 123,\n \"return_documents\": true\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "<authorization>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.gravitex.ai/v1/rerank")
.header("Authorization", "<authorization>")
.header("Content-Type", "application/json")
.body("{\n \"model\": \"<string>\",\n \"query\": \"<string>\",\n \"documents\": [\n {}\n ],\n \"top_n\": 123,\n \"return_documents\": true\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.gravitex.ai/v1/rerank")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = '<authorization>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"model\": \"<string>\",\n \"query\": \"<string>\",\n \"documents\": [\n {}\n ],\n \"top_n\": 123,\n \"return_documents\": true\n}"
response = http.request(request)
puts response.read_bodyIntroduction
Rerank a list of candidate documents by relevance to a query. Commonly used in RAG and knowledge-base search.Authentication
string
required
Bearer Token, e.g.
Bearer sk-xxxxxxxxxxRequest parameters
string
required
Rerank model, e.g.
rerank-english-v2.0string
required
Query text
array
required
Documents to rerank (strings or objects)
integer
Return top N results
boolean
default:"false"
Include document text in results
Request example
curl -X POST "https://api.gravitex.ai/v1/rerank" \
-H "Authorization: Bearer sk-xxxxxxxxxx" \
-H "Content-Type: application/json" \
-d '{
"model": "rerank-english-v2.0",
"query": "What is a vector database?",
"documents": [
"Vector databases store and search embeddings",
"Today is sunny",
"RAG pipelines often use reranking"
],
"top_n": 2,
"return_documents": true
}'
Common parameters
- query: User question or search query
- documents: Candidate passages
- top_n: Limit to top N hits
- return_documents: Include source text when
true
results array contains index and relevance_score, sorted by score.âI
