---
title: "Rerank documents based on relevance to a query."
method: POST
path: "/v1alpha/inference/rerank"
tags: ["Inference"]
---

# Rerank documents based on relevance to a query.

`POST /v1alpha/inference/rerank`

Rerank a list of documents based on their relevance to a query.

## Request body

- RerankRequest — Request model for reranking documents.
  - `model` string, required — The identifier of the reranking model to use.
  - `query` union, required — The search query to rank items against. Can be a string, text content part, or image content part.
    - string
    - OpenAIChatCompletionContentPartTextParam — Text content part for OpenAI-compatible chat completion messages.
      - `type` 'text' — Must be 'text' to identify this as text content.
      - `text` string, required — The text content of the message.
    - OpenAIChatCompletionContentPartImageParam — Image content part for OpenAI-compatible chat completion messages.
      - `type` 'image_url' — Must be 'image_url' to identify this as image content.
      - `image_url` OpenAIImageURL, required — Image URL specification for OpenAI-compatible chat completion messages.
        - `url` string, required — URL of the image to include in the message.
        - `detail` 'low' | 'high' | 'auto', nullable — Level of detail for image processing. Can be 'low', 'high', or 'auto'.
  - `items` union[], required — List of items to rerank. Each item can be a string, text content part, or image content part.
    - union
      - string
      - OpenAIChatCompletionContentPartTextParam — Text content part for OpenAI-compatible chat completion messages.
        - `type` 'text' — Must be 'text' to identify this as text content.
        - `text` string, required — The text content of the message.
      - OpenAIChatCompletionContentPartImageParam — Image content part for OpenAI-compatible chat completion messages.
        - `type` 'image_url' — Must be 'image_url' to identify this as image content.
        - `image_url` OpenAIImageURL, required — Image URL specification for OpenAI-compatible chat completion messages.
          - `url` string, required — URL of the image to include in the message.
          - `detail` 'low' | 'high' | 'auto', nullable — Level of detail for image processing. Can be 'low', 'high', or 'auto'.
  - `max_num_results` integer, nullable — Maximum number of results to return. Default: returns all.

## Response `200`

RerankResponse with indices sorted by relevance score (descending).

- RerankResponse — Response from a reranking request.
  - `data` RerankData[], required — List of rerank result objects, sorted by relevance score (descending).
    - `index` integer, required — The original index of the document in the input list.
    - `relevance_score` number, required — The relevance score from the model output. Higher scores indicate greater relevance.

## Other responses

- `400` — The request was invalid or malformed
- `429` — The client has sent too many requests in a given amount of time
- `500` — The server encountered an unexpected error
- `default` — An error occurred

---

[API](https://skmtc.net/ogx-ai/apis/ogx-specification-stable-experimental-apis.md) · [All operations](https://skmtc.net/ogx-ai/apis/ogx-specification-stable-experimental-apis/llms.txt) · [OpenAPI document](https://skmtc-service-staging.skmtc.workers.dev/v1/apis/ogx-ai/ogx-specification-stable-experimental-apis/versions/f3f783962256/schema)
