> ## Documentation Index
> Fetch the complete documentation index at: https://docs.tkhub.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# 文档重排序

> 根据查询对文档列表进行相关性重排序



## OpenAPI

````yaml /api.json post /v1/rerank
openapi: 3.0.1
info:
  title: TKHub API
  description: TKHub 平台 API 接口文档
  version: 1.0.0
servers:
  - url: https://api.tkhub.ai
    description: 生产环境
  - url: https://api-test.tkhub.ai
    description: 测试环境
security:
  - bearerAuth: []
paths:
  /v1/rerank:
    post:
      tags:
        - 重排序(Rerank)
      summary: 文档重排序
      description: 根据查询对文档列表进行相关性重排序
      operationId: createRerank
      parameters: []
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/RerankRequest'
        required: true
      responses:
        '200':
          description: 成功重排序
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/RerankResponse'
          headers: {}
      deprecated: false
      security:
        - BearerAuth: []
components:
  schemas:
    RerankRequest:
      type: object
      required:
        - model
        - query
        - documents
      properties:
        model:
          type: string
          example: rerank-english-v2.0
        query:
          type: string
          description: 查询文本
        documents:
          type: array
          items:
            oneOf:
              - type: string
              - type: object
                properties: {}
          description: 要重排序的文档列表
        top_n:
          type: integer
          description: 返回前 N 个结果
        return_documents:
          type: boolean
          default: false
    RerankResponse:
      type: object
      properties:
        id:
          type: string
        results:
          type: array
          items:
            type: object
            properties:
              index:
                type: integer
              relevance_score:
                type: number
              document:
                type: object
                properties: {}
        meta:
          type: object
          properties: {}
  securitySchemes:
    BearerAuth:
      type: http
      scheme: bearer
      description: |
        使用 Bearer Token 认证。
        格式: `Authorization: Bearer sk-xxxxxx`

````