重排序

POST /v1/rerank

MethodPOST
Path/v1/rerank
Typehttp
Status1
Module2102810
Folder61216487

说明

给定一个提示,该模型将返回一个或多个预测的完成,并且还可以返回每个位置的替代标记的概率。

为提供的提示和参数创建完成

官方文档:https://docs.siliconflow.cn/cn/api-reference/rerank/create-rerank

概览

MethodPOST
Path/v1/rerank
Typehttp
Status1
Module2102810
Folder61216487

参数

{
  "query": [],
  "path": [],
  "cookie": [],
  "header": [
    {
      "id": "NQs7bxnpZf",
      "name": "Content-Type",
      "required": true,
      "description": "",
      "type": "string",
      "enable": true,
      "sampleValue": "application/json"
    },
    {
      "id": "qb8tEQbCty",
      "name": "Accept",
      "required": true,
      "description": "",
      "type": "string",
      "enable": true,
      "sampleValue": "application/json"
    },
    {
      "required": false,
      "description": "",
      "type": "string",
      "id": "gBxcCbXhsa",
      "enable": true,
      "name": "Authorization",
      "sampleValue": "Bearer {{YOUR_API_KEY}}"
    },
    {
      "required": false,
      "description": "",
      "type": "string",
      "id": "t8P0euDZvz",
      "enable": false,
      "name": "X-Forwarded-Host",
      "sampleValue": "localhost:5173"
    }
  ]
}

请求体

{
  "type": "application/json",
  "parameters": [],
  "jsonSchema": {
    "type": "object",
    "properties": {
      "model": {
        "type": "string"
      },
      "documents": {
        "type": "array",
        "items": {
          "type": "string"
        }
      },
      "query": {
        "type": "string"
      },
      "top_n": {
        "type": "integer"
      },
      "instruct": {
        "type": "string"
      }
    },
    "required": [
      "model",
      "documents",
      "query",
      "top_n",
      "instruct"
    ],
    "x-apifox-orders": [
      "model",
      "documents",
      "query",
      "top_n",
      "instruct"
    ]
  },
  "mediaType": "",
  "examples": [
    {
      "value": " {\n    \"model\": \"qwen3-rerank\",\n    \"documents\": [\n        \"文本排序模型广泛用于搜索引擎 and 推荐系统中,它们根据文本相关性对候选文本进行排序\",\n        \"量子计算是计算科学的一个前沿领域\",\n        \"预训练语言模型的发展给文本排序模型带来了新的进展\"\n    ],\n    \"query\": \"什么是文本排序模型\",\n    \"top_n\": 2,\n    \"instruct\": \"Given a web search query, retrieve relevant passages that answer the query.\"\n}",
      "mediaType": "application/json"
    }
  ],
  "oasExtensions": ""
}

响应

[
  {
    "id": 717513032,
    "name": "OK",
    "code": 200,
    "contentType": "json",
    "jsonSchema": {
      "type": "object",
      "properties": {
        "id": {
          "type": "string"
        },
        "object": {
          "type": "string"
        },
        "created": {
          "type": "integer"
        },
        "choices": {
          "type": "array",
          "items": {
            "type": "object",
            "properties": {
              "index": {
                "type": "integer"
              },
              "message": {
                "type": "object",
                "properties": {
                  "role": {
                    "type": "string"
                  },
                  "content": {
                    "type": "string"
                  }
                },
                "required": [
                  "role",
                  "content"
                ],
                "x-apifox-orders": [
                  "role",
                  "content"
                ]
              },
              "finish_reason": {
                "type": "string"
              }
            },
            "x-apifox-orders": [
              "index",
              "message",
              "finish_reason"
            ]
          }
        },
        "usage": {
          "type": "object",
          "properties": {
            "prompt_tokens": {
              "type": "integer"
            },
            "completion_tokens": {
              "type": "integer"
            },
            "total_tokens": {
              "type": "integer"
            }
          },
          "required": [
            "prompt_tokens",
            "completion_tokens",
            "total_tokens"
          ],
          "x-apifox-orders": [
            "prompt_tokens",
            "completion_tokens",
            "total_tokens"
          ]
        }
      },
      "required": [
        "id",
        "object",
        "created",
        "choices",
        "usage"
      ],
      "x-apifox-orders": [
        "id",
        "object",
        "created",
        "choices",
        "usage"
      ]
    },
    "itemSchema": {},
    "description": "",
    "mediaType": "",
    "headers": [],
    "oasExtensions": ""
  }
]

响应示例

[
  {
    "name": "OK",
    "responseId": 717513032,
    "data": "{\n    \"id\": \"chatcmpl-123\",\n    \"object\": \"chat.completion\",\n    \"created\": 1677652288,\n    \"choices\": [\n        {\n            \"index\": 0,\n            \"message\": {\n                \"role\": \"assistant\",\n                \"content\": \"\\n\\nHello there, how may I assist you today?\"\n            },\n            \"finish_reason\": \"stop\"\n        }\n    ],\n    \"usage\": {\n        \"prompt_tokens\": 9,\n        \"completion_tokens\": 12,\n        \"total_tokens\": 21\n    }\n}",
    "description": "",
    "oasKey": "",
    "oasExtensions": "",
    "id": 634603861
  },
  {
    "name": "成功示例",
    "responseId": 717513032,
    "data": "{\r\n    \"results\": [\r\n        {\r\n            \"document\": {\r\n                \"text\": \"文本排序模型广泛用于搜索引擎 and 推荐系统中,它们根据文本相关性对候选文本进行排序\"\r\n            },\r\n            \"index\": 0,\r\n            \"relevance_score\": 0.915543128021105\r\n        },\r\n        {\r\n            \"document\": {\r\n                \"text\": \"预训练语言模型的发展给文本排序模型带来了新的进展\"\r\n            },\r\n            \"index\": 2,\r\n            \"relevance_score\": 0.7576691095659295\r\n        }\r\n    ],\r\n    \"usage\": {\r\n        \"prompt_tokens\": 107,\r\n        \"completion_tokens\": 0,\r\n        \"total_tokens\": 107,\r\n        \"prompt_tokens_details\": {\r\n            \"cached_tokens\": 0,\r\n            \"text_tokens\": 0,\r\n            \"audio_tokens\": 0,\r\n            \"image_tokens\": 0\r\n        },\r\n        \"completion_tokens_details\": {\r\n            \"text_tokens\": 0,\r\n            \"audio_tokens\": 0,\r\n            \"reasoning_tokens\": 0\r\n        },\r\n        \"input_tokens\": 0,\r\n        \"output_tokens\": 0,\r\n        \"input_tokens_details\": null\r\n    }\r\n}",
    "id": "019bc120-c865-77af-aaaf-8d0310b7e731"
  }
]