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"
  ]
}'
{
  "object": "rerank",
  "id": "9dfa1a09-5ebc-4a40-970f-586cb8f4ae47",
  "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.\"}"
      }
    }
  ],
  "usage": {
    "prompt_tokens": 1837,
    "completion_tokens": 0,
    "total_tokens": 1837
  }
}

Authorizations

Authorization
string
header
default:default
required

Bearer authentication header of the form Bearer <token>, where <token> is your auth token.

Body

application/json
model
required

The model to be used for the rerank request.<br> <br> See all of Together AI's rerank models

Available options:
Salesforce/Llama-Rank-v1
Example:

"Salesforce/Llama-Rank-V1"

query
string
required

The search query to be used for ranking.

Example:

"What animals can I find near Peru?"

documents
required

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."
}
]
top_n
integer

The number of top results to return.

Example:

2

return_documents
boolean

Whether to return supplied documents with the response.

Example:

true

rank_fields
string[]

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
enum<string>
required

Object type

Available options:
rerank
Example:

"rerank"

model
string
required

The model to be used for the rerank request.

Example:

"salesforce/turboranker-0.8-3778-6328"

results
object[]
required
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.\"}"
}
}
]
id
string

Request ID

Example:

"9dfa1a09-5ebc-4a40-970f-586cb8f4ae47"

usage
object | null