Skip to main content
POST
/
rerank
文本重排序接口
curl --request POST \
  --url https://geekai.co/api/v1/rerank \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '
{
  "model": "rerank-multilingual-v3.0",
  "query": "美国首都是哪里?",
  "documents": [
    "待重排文本1",
    "待重排文本2",
    "待重排文本3"
  ],
  "top_n": 10,
  "retries": 0
}
'
{
  "model": "rerank-multilingual-v3.0",
  "results": [
    {
      "index": 0,
      "relevance_score": 0.89,
      "document": "华盛顿特区是美国的首都"
    }
  ],
  "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

API认证token

Body

application/json
model
string
required

重排模型

Example:

"rerank-multilingual-v3.0"

query
string
required

重排提示

Example:

"美国首都是哪里?"

documents
string[]
required

用于重新排序的字符串数组

Example:
["待重排文本1", "待重排文本2", "待重排文本3"]
top_n
integer
default:10

返回前N个最匹配结果

Example:

10

retries
integer
default:0

自动重试次数,默认0,表示失败不重试

Example:

0

Response

成功响应

model
string
required

使用的重排模型

Example:

"rerank-multilingual-v3.0"

results
object[]
required

重排序结果列表

usage
object
required
metadata
object

额外的元数据信息