v4

latestOpenAPI 3.1.0MIT2026-08-04193459793.6 KB
Rerank

Create a rerank request

Rerank a list of documents by relevance to a query. Returns a relevance score and ordering index for each document.

post/rerank

Request body

querystring required

The search query to be used for ranking.

top_ninteger

The number of top results to return.

return_documentsboolean

Whether to return supplied documents with the response.

rank_fieldsstring[]

List of keys in the JSON Object document to rank by. Defaults to use all supplied keys for ranking.

Example request

{
  "query": "What animals can I find near Peru?",
  "documents": [
    "Our solar system orbits the Milky Way galaxy at about 515,000 mph"
  ],
  "top_n": 2,
  "return_documents": true,
  "rank_fields": [
    "title",
    "text"
  ]
}

Response

200

object'rerank' required

The object type, which is always rerank.

idstring

Request ID

modelstring required

The model to be used for the rerank request.

Example response

{
  "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.\"}"
      }
    }
  ]
}