---
title: "Create rerankings"
method: POST
path: "/2/ai/{product_id}/cohere/v2/rerank"
tags: ["Usage > V2 > Cohere-compatible"]
---

# Create rerankings

`POST /2/ai/{product_id}/cohere/v2/rerank`

This endpoint takes in a query and a list of texts and produces an ordered array with each text assigned a relevance score.<br>
It is intended to be *Cohere*-compliant, see their documentation: [Cohere: Rerank API (v2)](https://docs.Cohere.com/reference/rerank).<br>
The main discrepancy with the *Cohere* standard is on consumptions data:
while the *Cohere* standard is to return the object `meta`,
this endpoint returns an object `usage` that is closer to *OpenAI* endpoints,
especially the embedding one.

## Path parameters

- `product_id` integer, required

## Request body

- object
  - `documents` string[], required — A list of texts that will be compared to the `query`. For optimal performance we recommend against sending more than 1,000 documents in a single request.<br><br>**Note:** long documents will automatically be truncated to the value of `max_tokens_per_doc`.<br><br>**Note:** structured data should be formatted as YAML strings for best performance.
  - `max_tokens_per_doc` integer — **Defaults to `4096`**<br>Long documents will be automatically truncated to the specified number of tokens.
  - `model` string, required — Model name to use<br>You can use the endpoint [GET `/1/ai/models`](/docs/api/get/1/ai/models) to see all our available models with various information.
  - `priority` integer — **Defaults to `0`**<br>Controls how early the request is handled. Lower numbers indicate higher priority (default: `0`, the highest). When the system is under load, higher-priority requests are processed first and are the least likely to be dropped.
  - `query` string, required — The search query, *i.e.* the word/sentence/… to rank against `documents`
  - `top_n` integer — Limits the number of returned rerank results to the specified value. If not passed, all the rerank results will be returned.

## Response `200`

OK

- 4cee7ea0CohereV2Rerank — Response of *Cohere* `/v2/rerank` on **200 OK**.
  - `id` string, required
  - `model` string, required — The model name used (extra non-*Cohere* field).
  - `usage` 4cee7ea0CohereV2RerankUsage, required — Usage statistics (extra non-*Cohere* field).
    - `total_tokens` integer, required — Total number of tokens used in the request input
  - `results` 4cee7ea0CohereV2RerankResults[], required
    - `index` integer, required — Corresponds to the index in the original list of documents to which the ranked document belongs. (*i.e.* if the first value in the `results` object has an index value of `3`, it means in the list of documents passed in, the document at `index=3` had the highest relevance)
    - `document` 4cee7ea0CohereV2RerankDocument — Object about the original item in `documents` (extra non-*Cohere* field).
      - `text` string, required — The original item in `documents` in the request body.
      - `multi_modal` string, nullable, required
    - `relevance_score` number, required — Relevance scores are normalized to be in the range `[0, 1]`. Scores close to `1` indicate a high relevance to the query, and scores closer to `0` indicate low relevance. It is not accurate to assume a score of `0.9` means the document is 2x more relevant than a document with a score of `0.45`.
  - `meta` 4cee7ea0CohereV2RerankMeta — Object containing various information, including consumptions<br>This *Cohere* field is not returned by our endpoint.

---

[API](https://skmtc.dev/infomaniak/apis/api-reference-developer-tools.md) · [All operations](https://skmtc.dev/infomaniak/apis/api-reference-developer-tools/llms.txt) · [OpenAPI document](https://skmtc-service-production.skmtc.workers.dev/v1/apis/infomaniak/api-reference-developer-tools/revisions/667aae28fec6/schema)
