Create a rerank request
curl --request POST \
--url https://api.together.xyz/v1/rerank \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"model": "Salesforce/Llama-Rank-V1",
"query": "What animals can I find near Peru?",
"documents": [
{
"title": "Llama",
"text": "The llama is a domesticated South American camelid, widely used as a meat and pack animal by Andean cultures since the pre-Columbian era."
},
{
"title": "Panda",
"text": "The giant panda (Ailuropoda melanoleuca), also known as the panda bear or simply panda, is a bear species endemic to China."
},
{
"title": "Guanaco",
"text": "The guanaco is a camelid native to South America, closely related to the llama. Guanacos are one of two wild South American camelids; the other species is the vicuña, which lives at higher elevations."
},
{
"title": "Wild Bactrian camel",
"text": "The wild Bactrian camel (Camelus ferus) is an endangered species of camel endemic to Northwest China and southwestern Mongolia."
}
],
"top_n": 2,
"return_documents": true,
"rank_fields": [
"title",
"text"
]
}
'import requests
url = "https://api.together.xyz/v1/rerank"
payload = {
"model": "Salesforce/Llama-Rank-V1",
"query": "What animals can I find near Peru?",
"documents": [
{
"title": "Llama",
"text": "The llama is a domesticated South American camelid, widely used as a meat and pack animal by Andean cultures since the pre-Columbian era."
},
{
"title": "Panda",
"text": "The giant panda (Ailuropoda melanoleuca), also known as the panda bear or simply panda, is a bear species endemic to China."
},
{
"title": "Guanaco",
"text": "The guanaco is a camelid native to South America, closely related to the llama. Guanacos are one of two wild South American camelids; the other species is the vicuña, which lives at higher elevations."
},
{
"title": "Wild Bactrian camel",
"text": "The wild Bactrian camel (Camelus ferus) is an endangered species of camel endemic to Northwest China and southwestern Mongolia."
}
],
"top_n": 2,
"return_documents": True,
"rank_fields": ["title", "text"]
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
model: 'Salesforce/Llama-Rank-V1',
query: 'What animals can I find near Peru?',
documents: [
{
title: 'Llama',
text: 'The llama is a domesticated South American camelid, widely used as a meat and pack animal by Andean cultures since the pre-Columbian era.'
},
{
title: 'Panda',
text: 'The giant panda (Ailuropoda melanoleuca), also known as the panda bear or simply panda, is a bear species endemic to China.'
},
{
title: 'Guanaco',
text: 'The guanaco is a camelid native to South America, closely related to the llama. Guanacos are one of two wild South American camelids; the other species is the vicuña, which lives at higher elevations.'
},
{
title: 'Wild Bactrian camel',
text: 'The wild Bactrian camel (Camelus ferus) is an endangered species of camel endemic to Northwest China and southwestern Mongolia.'
}
],
top_n: 2,
return_documents: true,
rank_fields: ['title', 'text']
})
};
fetch('https://api.together.xyz/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.together.xyz/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' => 'Salesforce/Llama-Rank-V1',
'query' => 'What animals can I find near Peru?',
'documents' => [
[
'title' => 'Llama',
'text' => 'The llama is a domesticated South American camelid, widely used as a meat and pack animal by Andean cultures since the pre-Columbian era.'
],
[
'title' => 'Panda',
'text' => 'The giant panda (Ailuropoda melanoleuca), also known as the panda bear or simply panda, is a bear species endemic to China.'
],
[
'title' => 'Guanaco',
'text' => 'The guanaco is a camelid native to South America, closely related to the llama. Guanacos are one of two wild South American camelids; the other species is the vicuña, which lives at higher elevations.'
],
[
'title' => 'Wild Bactrian camel',
'text' => 'The wild Bactrian camel (Camelus ferus) is an endangered species of camel endemic to Northwest China and southwestern Mongolia.'
]
],
'top_n' => 2,
'return_documents' => true,
'rank_fields' => [
'title',
'text'
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"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.together.xyz/v1/rerank"
payload := strings.NewReader("{\n \"model\": \"Salesforce/Llama-Rank-V1\",\n \"query\": \"What animals can I find near Peru?\",\n \"documents\": [\n {\n \"title\": \"Llama\",\n \"text\": \"The llama is a domesticated South American camelid, widely used as a meat and pack animal by Andean cultures since the pre-Columbian era.\"\n },\n {\n \"title\": \"Panda\",\n \"text\": \"The giant panda (Ailuropoda melanoleuca), also known as the panda bear or simply panda, is a bear species endemic to China.\"\n },\n {\n \"title\": \"Guanaco\",\n \"text\": \"The guanaco is a camelid native to South America, closely related to the llama. Guanacos are one of two wild South American camelids; the other species is the vicuña, which lives at higher elevations.\"\n },\n {\n \"title\": \"Wild Bactrian camel\",\n \"text\": \"The wild Bactrian camel (Camelus ferus) is an endangered species of camel endemic to Northwest China and southwestern Mongolia.\"\n }\n ],\n \"top_n\": 2,\n \"return_documents\": true,\n \"rank_fields\": [\n \"title\",\n \"text\"\n ]\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
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.together.xyz/v1/rerank")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"model\": \"Salesforce/Llama-Rank-V1\",\n \"query\": \"What animals can I find near Peru?\",\n \"documents\": [\n {\n \"title\": \"Llama\",\n \"text\": \"The llama is a domesticated South American camelid, widely used as a meat and pack animal by Andean cultures since the pre-Columbian era.\"\n },\n {\n \"title\": \"Panda\",\n \"text\": \"The giant panda (Ailuropoda melanoleuca), also known as the panda bear or simply panda, is a bear species endemic to China.\"\n },\n {\n \"title\": \"Guanaco\",\n \"text\": \"The guanaco is a camelid native to South America, closely related to the llama. Guanacos are one of two wild South American camelids; the other species is the vicuña, which lives at higher elevations.\"\n },\n {\n \"title\": \"Wild Bactrian camel\",\n \"text\": \"The wild Bactrian camel (Camelus ferus) is an endangered species of camel endemic to Northwest China and southwestern Mongolia.\"\n }\n ],\n \"top_n\": 2,\n \"return_documents\": true,\n \"rank_fields\": [\n \"title\",\n \"text\"\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.together.xyz/v1/rerank")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"model\": \"Salesforce/Llama-Rank-V1\",\n \"query\": \"What animals can I find near Peru?\",\n \"documents\": [\n {\n \"title\": \"Llama\",\n \"text\": \"The llama is a domesticated South American camelid, widely used as a meat and pack animal by Andean cultures since the pre-Columbian era.\"\n },\n {\n \"title\": \"Panda\",\n \"text\": \"The giant panda (Ailuropoda melanoleuca), also known as the panda bear or simply panda, is a bear species endemic to China.\"\n },\n {\n \"title\": \"Guanaco\",\n \"text\": \"The guanaco is a camelid native to South America, closely related to the llama. Guanacos are one of two wild South American camelids; the other species is the vicuña, which lives at higher elevations.\"\n },\n {\n \"title\": \"Wild Bactrian camel\",\n \"text\": \"The wild Bactrian camel (Camelus ferus) is an endangered species of camel endemic to Northwest China and southwestern Mongolia.\"\n }\n ],\n \"top_n\": 2,\n \"return_documents\": true,\n \"rank_fields\": [\n \"title\",\n \"text\"\n ]\n}"
response = http.request(request)
puts response.read_body{
"object": "rerank",
"model": "salesforce/turboranker-0.8-3778-6328",
"results": [
{
"index": 0,
"relevance_score": 0.29980177813003117,
"document": {
"text": "{\"title\":\"Llama\",\"text\":\"The llama is a domesticated South American camelid, widely used as a meat and pack animal by Andean cultures since the pre-Columbian era.\"}"
}
},
{
"index": 2,
"relevance_score": 0.2752447527354349,
"document": {
"text": "{\"title\":\"Guanaco\",\"text\":\"The guanaco is a camelid native to South America, closely related to the llama. Guanacos are one of two wild South American camelids; the other species is the vicuña, which lives at higher elevations.\"}"
}
}
],
"id": "9dfa1a09-5ebc-4a40-970f-586cb8f4ae47",
"usage": {
"prompt_tokens": 1837,
"completion_tokens": 0,
"total_tokens": 1837
}
}{
"error": {
"message": "<string>",
"type": "<string>",
"param": null,
"code": null
}
}{
"error": {
"message": "<string>",
"type": "<string>",
"param": null,
"code": null
}
}{
"error": {
"message": "<string>",
"type": "<string>",
"param": null,
"code": null
}
}{
"error": {
"message": "<string>",
"type": "<string>",
"param": null,
"code": null
}
}{
"error": {
"message": "<string>",
"type": "<string>",
"param": null,
"code": null
}
}{
"error": {
"message": "<string>",
"type": "<string>",
"param": null,
"code": null
}
}Rerank
Create A Rerank Request
Query a reranker model
POST
/
rerank
Create a rerank request
curl --request POST \
--url https://api.together.xyz/v1/rerank \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"model": "Salesforce/Llama-Rank-V1",
"query": "What animals can I find near Peru?",
"documents": [
{
"title": "Llama",
"text": "The llama is a domesticated South American camelid, widely used as a meat and pack animal by Andean cultures since the pre-Columbian era."
},
{
"title": "Panda",
"text": "The giant panda (Ailuropoda melanoleuca), also known as the panda bear or simply panda, is a bear species endemic to China."
},
{
"title": "Guanaco",
"text": "The guanaco is a camelid native to South America, closely related to the llama. Guanacos are one of two wild South American camelids; the other species is the vicuña, which lives at higher elevations."
},
{
"title": "Wild Bactrian camel",
"text": "The wild Bactrian camel (Camelus ferus) is an endangered species of camel endemic to Northwest China and southwestern Mongolia."
}
],
"top_n": 2,
"return_documents": true,
"rank_fields": [
"title",
"text"
]
}
'import requests
url = "https://api.together.xyz/v1/rerank"
payload = {
"model": "Salesforce/Llama-Rank-V1",
"query": "What animals can I find near Peru?",
"documents": [
{
"title": "Llama",
"text": "The llama is a domesticated South American camelid, widely used as a meat and pack animal by Andean cultures since the pre-Columbian era."
},
{
"title": "Panda",
"text": "The giant panda (Ailuropoda melanoleuca), also known as the panda bear or simply panda, is a bear species endemic to China."
},
{
"title": "Guanaco",
"text": "The guanaco is a camelid native to South America, closely related to the llama. Guanacos are one of two wild South American camelids; the other species is the vicuña, which lives at higher elevations."
},
{
"title": "Wild Bactrian camel",
"text": "The wild Bactrian camel (Camelus ferus) is an endangered species of camel endemic to Northwest China and southwestern Mongolia."
}
],
"top_n": 2,
"return_documents": True,
"rank_fields": ["title", "text"]
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
model: 'Salesforce/Llama-Rank-V1',
query: 'What animals can I find near Peru?',
documents: [
{
title: 'Llama',
text: 'The llama is a domesticated South American camelid, widely used as a meat and pack animal by Andean cultures since the pre-Columbian era.'
},
{
title: 'Panda',
text: 'The giant panda (Ailuropoda melanoleuca), also known as the panda bear or simply panda, is a bear species endemic to China.'
},
{
title: 'Guanaco',
text: 'The guanaco is a camelid native to South America, closely related to the llama. Guanacos are one of two wild South American camelids; the other species is the vicuña, which lives at higher elevations.'
},
{
title: 'Wild Bactrian camel',
text: 'The wild Bactrian camel (Camelus ferus) is an endangered species of camel endemic to Northwest China and southwestern Mongolia.'
}
],
top_n: 2,
return_documents: true,
rank_fields: ['title', 'text']
})
};
fetch('https://api.together.xyz/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.together.xyz/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' => 'Salesforce/Llama-Rank-V1',
'query' => 'What animals can I find near Peru?',
'documents' => [
[
'title' => 'Llama',
'text' => 'The llama is a domesticated South American camelid, widely used as a meat and pack animal by Andean cultures since the pre-Columbian era.'
],
[
'title' => 'Panda',
'text' => 'The giant panda (Ailuropoda melanoleuca), also known as the panda bear or simply panda, is a bear species endemic to China.'
],
[
'title' => 'Guanaco',
'text' => 'The guanaco is a camelid native to South America, closely related to the llama. Guanacos are one of two wild South American camelids; the other species is the vicuña, which lives at higher elevations.'
],
[
'title' => 'Wild Bactrian camel',
'text' => 'The wild Bactrian camel (Camelus ferus) is an endangered species of camel endemic to Northwest China and southwestern Mongolia.'
]
],
'top_n' => 2,
'return_documents' => true,
'rank_fields' => [
'title',
'text'
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"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.together.xyz/v1/rerank"
payload := strings.NewReader("{\n \"model\": \"Salesforce/Llama-Rank-V1\",\n \"query\": \"What animals can I find near Peru?\",\n \"documents\": [\n {\n \"title\": \"Llama\",\n \"text\": \"The llama is a domesticated South American camelid, widely used as a meat and pack animal by Andean cultures since the pre-Columbian era.\"\n },\n {\n \"title\": \"Panda\",\n \"text\": \"The giant panda (Ailuropoda melanoleuca), also known as the panda bear or simply panda, is a bear species endemic to China.\"\n },\n {\n \"title\": \"Guanaco\",\n \"text\": \"The guanaco is a camelid native to South America, closely related to the llama. Guanacos are one of two wild South American camelids; the other species is the vicuña, which lives at higher elevations.\"\n },\n {\n \"title\": \"Wild Bactrian camel\",\n \"text\": \"The wild Bactrian camel (Camelus ferus) is an endangered species of camel endemic to Northwest China and southwestern Mongolia.\"\n }\n ],\n \"top_n\": 2,\n \"return_documents\": true,\n \"rank_fields\": [\n \"title\",\n \"text\"\n ]\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
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.together.xyz/v1/rerank")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"model\": \"Salesforce/Llama-Rank-V1\",\n \"query\": \"What animals can I find near Peru?\",\n \"documents\": [\n {\n \"title\": \"Llama\",\n \"text\": \"The llama is a domesticated South American camelid, widely used as a meat and pack animal by Andean cultures since the pre-Columbian era.\"\n },\n {\n \"title\": \"Panda\",\n \"text\": \"The giant panda (Ailuropoda melanoleuca), also known as the panda bear or simply panda, is a bear species endemic to China.\"\n },\n {\n \"title\": \"Guanaco\",\n \"text\": \"The guanaco is a camelid native to South America, closely related to the llama. Guanacos are one of two wild South American camelids; the other species is the vicuña, which lives at higher elevations.\"\n },\n {\n \"title\": \"Wild Bactrian camel\",\n \"text\": \"The wild Bactrian camel (Camelus ferus) is an endangered species of camel endemic to Northwest China and southwestern Mongolia.\"\n }\n ],\n \"top_n\": 2,\n \"return_documents\": true,\n \"rank_fields\": [\n \"title\",\n \"text\"\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.together.xyz/v1/rerank")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"model\": \"Salesforce/Llama-Rank-V1\",\n \"query\": \"What animals can I find near Peru?\",\n \"documents\": [\n {\n \"title\": \"Llama\",\n \"text\": \"The llama is a domesticated South American camelid, widely used as a meat and pack animal by Andean cultures since the pre-Columbian era.\"\n },\n {\n \"title\": \"Panda\",\n \"text\": \"The giant panda (Ailuropoda melanoleuca), also known as the panda bear or simply panda, is a bear species endemic to China.\"\n },\n {\n \"title\": \"Guanaco\",\n \"text\": \"The guanaco is a camelid native to South America, closely related to the llama. Guanacos are one of two wild South American camelids; the other species is the vicuña, which lives at higher elevations.\"\n },\n {\n \"title\": \"Wild Bactrian camel\",\n \"text\": \"The wild Bactrian camel (Camelus ferus) is an endangered species of camel endemic to Northwest China and southwestern Mongolia.\"\n }\n ],\n \"top_n\": 2,\n \"return_documents\": true,\n \"rank_fields\": [\n \"title\",\n \"text\"\n ]\n}"
response = http.request(request)
puts response.read_body{
"object": "rerank",
"model": "salesforce/turboranker-0.8-3778-6328",
"results": [
{
"index": 0,
"relevance_score": 0.29980177813003117,
"document": {
"text": "{\"title\":\"Llama\",\"text\":\"The llama is a domesticated South American camelid, widely used as a meat and pack animal by Andean cultures since the pre-Columbian era.\"}"
}
},
{
"index": 2,
"relevance_score": 0.2752447527354349,
"document": {
"text": "{\"title\":\"Guanaco\",\"text\":\"The guanaco is a camelid native to South America, closely related to the llama. Guanacos are one of two wild South American camelids; the other species is the vicuña, which lives at higher elevations.\"}"
}
}
],
"id": "9dfa1a09-5ebc-4a40-970f-586cb8f4ae47",
"usage": {
"prompt_tokens": 1837,
"completion_tokens": 0,
"total_tokens": 1837
}
}{
"error": {
"message": "<string>",
"type": "<string>",
"param": null,
"code": null
}
}{
"error": {
"message": "<string>",
"type": "<string>",
"param": null,
"code": null
}
}{
"error": {
"message": "<string>",
"type": "<string>",
"param": null,
"code": null
}
}{
"error": {
"message": "<string>",
"type": "<string>",
"param": null,
"code": null
}
}{
"error": {
"message": "<string>",
"type": "<string>",
"param": null,
"code": null
}
}{
"error": {
"message": "<string>",
"type": "<string>",
"param": null,
"code": null
}
}Authorizations
Bearer authentication header of the form Bearer <token>, where <token> is your auth token.
Body
application/json
The model to be used for the rerank request.
See all of Together AI's rerank models
Available options:
Salesforce/Llama-Rank-v1 Example:
"Salesforce/Llama-Rank-V1"
The search query to be used for ranking.
Example:
"What animals can I find near Peru?"
List of documents, which can be either strings or objects.
Example:
[
{
"title": "Llama",
"text": "The llama is a domesticated South American camelid, widely used as a meat and pack animal by Andean cultures since the pre-Columbian era."
},
{
"title": "Panda",
"text": "The giant panda (Ailuropoda melanoleuca), also known as the panda bear or simply panda, is a bear species endemic to China."
},
{
"title": "Guanaco",
"text": "The guanaco is a camelid native to South America, closely related to the llama. Guanacos are one of two wild South American camelids; the other species is the vicuña, which lives at higher elevations."
},
{
"title": "Wild Bactrian camel",
"text": "The wild Bactrian camel (Camelus ferus) is an endangered species of camel endemic to Northwest China and southwestern Mongolia."
}
]
The number of top results to return.
Example:
2
Whether to return supplied documents with the response.
Example:
true
List of keys in the JSON Object document to rank by. Defaults to use all supplied keys for ranking.
Example:
["title", "text"]
Response
200
Object type
Available options:
rerank Example:
"rerank"
The model to be used for the rerank request.
Example:
"salesforce/turboranker-0.8-3778-6328"
Show child attributes
Show child attributes
Example:
[
{
"index": 0,
"relevance_score": 0.29980177813003117,
"document": {
"text": "{\"title\":\"Llama\",\"text\":\"The llama is a domesticated South American camelid, widely used as a meat and pack animal by Andean cultures since the pre-Columbian era.\"}"
}
},
{
"index": 2,
"relevance_score": 0.2752447527354349,
"document": {
"text": "{\"title\":\"Guanaco\",\"text\":\"The guanaco is a camelid native to South America, closely related to the llama. Guanacos are one of two wild South American camelids; the other species is the vicuña, which lives at higher elevations.\"}"
}
}
]
Request ID
Example:
"9dfa1a09-5ebc-4a40-970f-586cb8f4ae47"
Show child attributes
Show child attributes
Example:
{
"prompt_tokens": 1837,
"completion_tokens": 0,
"total_tokens": 1837
}