---
title: "Rerank documents"
method: POST
path: "/rerank"
---

# Rerank documents

`POST /rerank`

Rerank documents for a query using relevance scoring

## Request body

- CreateRerankRequest
  - `model` string, nullable — The name of the reranker model to use.
  - `query` string, required — The search query to use for reranking documents.
  - `documents` string[], required — A list of documents to rerank. Each document is a string.
  - `top_n` integer, nullable — The number of most relevant documents to return. If not specified, all documents are returned.
  - `return_documents` boolean — Whether to return the document text in the response. Defaults to true.
  - `task` string, nullable — Optional task description to guide the reranking process.

## Response `200`

OK

- CreateRerankResponse
  - `object` 'list', required — The object type, which is always "list".
  - `model` string, required — The name of the model used for reranking.
  - `data` RerankResult[], required — The list of reranked documents, ordered by relevance score (highest first).
    - `index` integer, required — The original index of the document in the input array.
    - `relevance_score` number, float, required — The relevance score between 0 and 1, with higher scores indicating greater relevance.
    - `document` string, nullable — The document text. Only included if return_documents is true.
  - `usage` object, required — The usage information for the request.
    - `prompt_tokens` integer, required — The number of tokens used by the prompt.
    - `total_tokens` integer, required — The total number of tokens used by the request.

---

[API](https://skmtc.net/fireworks/apis/fireworks-ai-anthropic-compatible-messages-api.md) · [All operations](https://skmtc.net/fireworks/apis/fireworks-ai-anthropic-compatible-messages-api/llms.txt) · [OpenAPI document](https://skmtc-service-staging.skmtc.workers.dev/v1/apis/fireworks/fireworks-ai-anthropic-compatible-messages-api/versions/954d6bc5d922/schema)
