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

# Reranking

> Rank candidate documents by their relevance to a query through one gateway contract.

`POST /v1/rerank` scores and reorders candidate documents against a query. It is commonly used after vector or keyword retrieval to improve the final context sent to a generation model.

## Rerank Documents

```bash theme={null}
curl https://api.inquantum.ai/v1/rerank \
  -H "Authorization: Bearer $PLANCK_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "fireworks/qwen3-reranker-8b",
    "query": "How do I reset my API key?",
    "documents": [
      "Open the API Keys page and select Rotate key.",
      "Invoices are available from the Billing page.",
      "You can change your display name in Profile settings."
    ],
    "top_n": 2,
    "return_documents": true
  }'
```

A successful response contains normalized `results`, ordered from highest to lowest relevance. Every result includes its original document `index` and a `relevance_score`.

## Choosing a Model

Copy the exact rerank model ID from the model registry, including every `/`-separated part.

You always call the same Planck endpoint with your Planck API key. Some rerank models may require BYOK when their billing usage cannot be verified safely.

<Note>
  Reranking is not part of the OpenAI or Anthropic chat SDK surface. Call the
  JSON endpoint directly with `fetch`, your HTTP client, or cURL.
</Note>

## Billing and Tracking

Rerank requests appear in **Requests** with `Planck-Operation: rerank`, the resolved provider/model identity, duration, billing data when available, and the request and normalized response bodies.

See the [Rerank API reference](/rest/ai-gateway/post-v1-rerank) for supported fields and response shape.
