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

# Rank texts relative to a query



## OpenAPI

````yaml /api-reference/openapi.json post /v1/rerank
openapi: 3.1.0
info:
  title: SynapsAI Inference API
  version: 1.0.0
servers:
  - url: https://api.synapsai.cloud
    description: Production server
security: []
paths:
  /v1/rerank:
    post:
      summary: Rank texts relative to a query
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/SentenceRankingRequest'
      responses:
        '200':
          description: Ranking results (pipeline output)
          content:
            application/json:
              schema:
                type: object
                properties:
                  results:
                    type: array
                    items:
                      type: object
                      properties:
                        index:
                          type: integer
                        relevance_score:
                          type: number
                        document:
                          type: string
components:
  schemas:
    SentenceRankingRequest:
      allOf:
        - type: object
          description: Request to rank texts against a query.
          properties:
            query:
              oneOf:
                - type: string
                - type: array
                  items:
                    type: string
              description: Query string(s) used to rank provided documents. Required.
            documents:
              oneOf:
                - type: array
                  items:
                    type: string
                - type: array
                  items:
                    type: array
                    items:
                      type: string
              description: >-
                Documents to rerank; can be a flat list or grouped lists
                corresponding to multiple queries. Required.
            top_n:
              type: integer
              description: Maximum number of reranked results to return.
            max_tokens_per_doc:
              type: integer
              description: >-
                Maximum number of tokens to consider per document during
                reranking.
          required:
            - query
            - documents

````