# Rerank documents

Reorder candidate documents by relevance to a query and obtain relevance scores and original document positions.

## Prerequisites

Prepare a personal access token or service account API Key with Genesis permissions. See [Access credentials](../../../../guides/billing/credentials.md#choose-credential-type). [Find and select a model](models.md) for reranking, and prepare a query and a nonempty candidate document list.

## Call sequence

1. Preserve the original candidate order and [rerank documents](../../../../reference/api/genesis/text-reranking/rerank.md) using the selected model, query, and candidate list.
2. Read relevance scores and original document indices, and associate results with the candidate list.
3. Use the returned ranking in your application. To limit the number of returned results, configure the limit as described on the action page.

## API operations

| Task | API operation | When to use it or what to check |
| --- | --- | --- |
| Rank candidates by relevance | [Rerank documents](../../../../reference/api/genesis/text-reranking/rerank.md) | Use after preparing a query and candidates to obtain scores and original indices. |

## Confirm the result

Confirm that each result maps to an original candidate and that the number of returned results matches the request configuration.

## Limitations and notes

Reranking processes the candidates supplied in the request. Preserve their order before sending the request to avoid associating returned indices with the wrong documents.
