curl -X POST "https://t.ato2.nodesms.com/v1/rerank" \
-H "Authorization: Bearer $API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "rerank-english-v2.0",
"query": "What is the capital of the United States?",
"documents": [
"Carson City is the capital city of the American state of Nevada.",
"The Commonwealth of the Northern Mariana Islands is a group of islands in the Pacific Ocean. Its capital is Saipan.",
"Washington, D.C. is the capital of the United States.",
"Capital punishment has existed in the United States since before it was a country."
],
"top_n": 3
}'
from openai import OpenAI
client = OpenAI(
api_key="sk-xxxxxx",
base_url="https://t.ato2.nodesms.com/v1"
)
response = client.post(
"/rerank",
json={
"model": "rerank-english-v2.0",
"query": "What is the capital of the United States?",
"documents": [
"Carson City is the capital city of the American state of Nevada.",
"Washington, D.C. is the capital of the United States."
],
"top_n": 2
}
)
print(response.json())
{
"id": "string",
"results": [
{
"index": 2,
"relevance_score": 0.9871293,
"document": {}
},
{
"index": 1,
"relevance_score": 0.3456789,
"document": {}
}
],
"meta": {}
}
重排序
根据查询对文档列表进行相关性重排序,返回按相关性排序的结果。
POST
/
v1
/
rerank
curl -X POST "https://t.ato2.nodesms.com/v1/rerank" \
-H "Authorization: Bearer $API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "rerank-english-v2.0",
"query": "What is the capital of the United States?",
"documents": [
"Carson City is the capital city of the American state of Nevada.",
"The Commonwealth of the Northern Mariana Islands is a group of islands in the Pacific Ocean. Its capital is Saipan.",
"Washington, D.C. is the capital of the United States.",
"Capital punishment has existed in the United States since before it was a country."
],
"top_n": 3
}'
from openai import OpenAI
client = OpenAI(
api_key="sk-xxxxxx",
base_url="https://t.ato2.nodesms.com/v1"
)
response = client.post(
"/rerank",
json={
"model": "rerank-english-v2.0",
"query": "What is the capital of the United States?",
"documents": [
"Carson City is the capital city of the American state of Nevada.",
"Washington, D.C. is the capital of the United States."
],
"top_n": 2
}
)
print(response.json())
{
"id": "string",
"results": [
{
"index": 2,
"relevance_score": 0.9871293,
"document": {}
},
{
"index": 1,
"relevance_score": 0.3456789,
"document": {}
}
],
"meta": {}
}
请求头
string
必填
使用 Bearer Token 认证。格式:
Authorization: Bearer sk-xxxxxx请求体
格式:application/json
string
必填
模型 ID
string
必填
查询文本
(string | object)[]
必填
要重排序的文档列表
integer
返回前 N 个结果
boolean
默认值:"false"
是否在结果中返回原始文档内容
响应
200 成功重排序
格式:application/json
string
重排序任务 ID
object
元数据
curl -X POST "https://t.ato2.nodesms.com/v1/rerank" \
-H "Authorization: Bearer $API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "rerank-english-v2.0",
"query": "What is the capital of the United States?",
"documents": [
"Carson City is the capital city of the American state of Nevada.",
"The Commonwealth of the Northern Mariana Islands is a group of islands in the Pacific Ocean. Its capital is Saipan.",
"Washington, D.C. is the capital of the United States.",
"Capital punishment has existed in the United States since before it was a country."
],
"top_n": 3
}'
from openai import OpenAI
client = OpenAI(
api_key="sk-xxxxxx",
base_url="https://t.ato2.nodesms.com/v1"
)
response = client.post(
"/rerank",
json={
"model": "rerank-english-v2.0",
"query": "What is the capital of the United States?",
"documents": [
"Carson City is the capital city of the American state of Nevada.",
"Washington, D.C. is the capital of the United States."
],
"top_n": 2
}
)
print(response.json())
{
"id": "string",
"results": [
{
"index": 2,
"relevance_score": 0.9871293,
"document": {}
},
{
"index": 1,
"relevance_score": 0.3456789,
"document": {}
}
],
"meta": {}
}
最后修改于 2026年10月28日
此页面对您有帮助吗?