文本重排序接口
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
}
'import requests
url = "https://geekai.co/api/v1/rerank"
payload = {
"model": "rerank-multilingual-v3.0",
"query": "美国首都是哪里?",
"documents": ["待重排文本1", "待重排文本2", "待重排文本3"],
"top_n": 10,
"retries": 0
}
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: 'rerank-multilingual-v3.0',
query: '美国首都是哪里?',
documents: ['待重排文本1', '待重排文本2', '待重排文本3'],
top_n: 10,
retries: 0
})
};
fetch('https://geekai.co/api/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://geekai.co/api/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' => 'rerank-multilingual-v3.0',
'query' => '美国首都是哪里?',
'documents' => [
'待重排文本1',
'待重排文本2',
'待重排文本3'
],
'top_n' => 10,
'retries' => 0
]),
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://geekai.co/api/v1/rerank"
payload := strings.NewReader("{\n \"model\": \"rerank-multilingual-v3.0\",\n \"query\": \"美国首都是哪里?\",\n \"documents\": [\n \"待重排文本1\",\n \"待重排文本2\",\n \"待重排文本3\"\n ],\n \"top_n\": 10,\n \"retries\": 0\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://geekai.co/api/v1/rerank")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"model\": \"rerank-multilingual-v3.0\",\n \"query\": \"美国首都是哪里?\",\n \"documents\": [\n \"待重排文本1\",\n \"待重排文本2\",\n \"待重排文本3\"\n ],\n \"top_n\": 10,\n \"retries\": 0\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://geekai.co/api/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\": \"rerank-multilingual-v3.0\",\n \"query\": \"美国首都是哪里?\",\n \"documents\": [\n \"待重排文本1\",\n \"待重排文本2\",\n \"待重排文本3\"\n ],\n \"top_n\": 10,\n \"retries\": 0\n}"
response = http.request(request)
puts response.read_body{
"model": "rerank-multilingual-v3.0",
"results": [
{
"index": 0,
"relevance_score": 0.89,
"document": "华盛顿特区是美国的首都"
}
],
"usage": {
"total_tokens": 256,
"query_tokens": 32,
"documents_tokens": 224
},
"metadata": {}
}{
"code": "validation_error",
"message": "参数验证失败",
"details": {
"field": "错误描述"
}
}{
"code": "unauthorized",
"message": "Invalid API key or token"
}{
"code": "invalid_request",
"message": "请求参数不合法"
}{
"code": "invalid_request",
"message": "请求参数不合法"
}Chat
Rerank
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
}
'import requests
url = "https://geekai.co/api/v1/rerank"
payload = {
"model": "rerank-multilingual-v3.0",
"query": "美国首都是哪里?",
"documents": ["待重排文本1", "待重排文本2", "待重排文本3"],
"top_n": 10,
"retries": 0
}
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: 'rerank-multilingual-v3.0',
query: '美国首都是哪里?',
documents: ['待重排文本1', '待重排文本2', '待重排文本3'],
top_n: 10,
retries: 0
})
};
fetch('https://geekai.co/api/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://geekai.co/api/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' => 'rerank-multilingual-v3.0',
'query' => '美国首都是哪里?',
'documents' => [
'待重排文本1',
'待重排文本2',
'待重排文本3'
],
'top_n' => 10,
'retries' => 0
]),
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://geekai.co/api/v1/rerank"
payload := strings.NewReader("{\n \"model\": \"rerank-multilingual-v3.0\",\n \"query\": \"美国首都是哪里?\",\n \"documents\": [\n \"待重排文本1\",\n \"待重排文本2\",\n \"待重排文本3\"\n ],\n \"top_n\": 10,\n \"retries\": 0\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://geekai.co/api/v1/rerank")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"model\": \"rerank-multilingual-v3.0\",\n \"query\": \"美国首都是哪里?\",\n \"documents\": [\n \"待重排文本1\",\n \"待重排文本2\",\n \"待重排文本3\"\n ],\n \"top_n\": 10,\n \"retries\": 0\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://geekai.co/api/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\": \"rerank-multilingual-v3.0\",\n \"query\": \"美国首都是哪里?\",\n \"documents\": [\n \"待重排文本1\",\n \"待重排文本2\",\n \"待重排文本3\"\n ],\n \"top_n\": 10,\n \"retries\": 0\n}"
response = http.request(request)
puts response.read_body{
"model": "rerank-multilingual-v3.0",
"results": [
{
"index": 0,
"relevance_score": 0.89,
"document": "华盛顿特区是美国的首都"
}
],
"usage": {
"total_tokens": 256,
"query_tokens": 32,
"documents_tokens": 224
},
"metadata": {}
}{
"code": "validation_error",
"message": "参数验证失败",
"details": {
"field": "错误描述"
}
}{
"code": "unauthorized",
"message": "Invalid API key or token"
}{
"code": "invalid_request",
"message": "请求参数不合法"
}{
"code": "invalid_request",
"message": "请求参数不合法"
}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
bearerAuthapiKeyAuth
API认证token
Body
application/json
Was this page helpful?
⌘I
