POST
/
rerank
curl --request POST \
  --url https://geekai.dev/api/v1/rerank \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '{
  "model": "rerank-multilingual-v3.0",
  "query": "Where is the capital of the United States?",
  "documents": [
    "text 1",
    "text 2",
    "text 3"
  ],
  "top_n": 10,
  "retries": 0
}'
{
  "model": "rerank-multilingual-v3.0",
  "results": [
    {
      "document": "Washington, D.C. is the capital of the United States.",
      "index": 0,
      "relevance_score": 0.89
    }
  ],
  "usage": {
    "total_tokens": 256,
    "query_tokens": 32,
    "documents_tokens": 224
  },
  "metadata": {}
}

Note: For setting the embedding model name, refer to the System Supported Rerank Models List. When switching models, you only need to modify the corresponding model name. The response data format is fully compatible with OpenAI.

cURL Request Example

curl --location 'https://geekai.dev/api/v1/rerank' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer {YOUR_GEEKAI_API_KEY}' \
--data '{
    "model": "rerank-multilingual-v3.0",
    "query": "Where is the capital of the United States?",
    "top_n": 3,
    "documents": [
        "Carson City is the capital of the U.S. state of Nevada.",
        "The Commonwealth of the Northern Mariana Islands is a group of islands located in the Pacific Ocean, and its capital is Saipan.",
        "Washington, D.C. (also known simply as Washington or D.C., and officially as the District of Columbia) is the capital of the United States, and it is a federal district.",
        "In English grammar, capitalization is the rule of using a capital letter at the beginning of a word, and the use of English differs from the capitalization rules of other languages.",
        "The existence of the death penalty in the United States dates back to before the United States became a country, and as of 2017, the death penalty is legal in 30 of the 50 states."
    ]
}

Authorizations

Authorization
string
header
required

token

Body

application/json

Response

200
application/json

successful response

The response is of type object.