Usage > V2 > Cohere-compatible

Create rerankings

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).<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.

post/2/ai/{product_id}/cohere/v2/rerank

Path parameters

product_idinteger required

AI Tools product identifier: use GET /1/ai to retrieve your product identifier.

Request body

documentsstring[] 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_docinteger

Defaults to 4096<br>Long documents will be automatically truncated to the specified number of tokens.

modelstring required

Model name to use<br>You can use the endpoint GET /1/ai/models to see all our available models with various information.

priorityinteger

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.

querystring required

The search query, i.e. the word/sentence/… to rank against documents

top_ninteger

Limits the number of returned rerank results to the specified value. If not passed, all the rerank results will be returned.

Example request

{
  "documents": [
    "Osmium is the densest metal."
  ],
  "model": "BAAI/bge-reranker-v2-m3",
  "query": "Osmium, Iridium and Platinum are the 3 densest metals."
}

Response

OK

idstring required
modelstring required

The model name used (extra non-Cohere field).

meta4cee7ea0CohereV2RerankMeta

Object containing various information, including consumptions<br>This Cohere field is not returned by our endpoint.

Example response

{
  "id": "rerank-a5dca720-5abc-4331-a8cf-1655693a27e1",
  "model": "BAAI/bge-reranker-v2-m3",
  "results": [
    {
      "index": 42,
      "document": {
        "text": "Silver is the metal with the highest electrical and thermal conductivity.",
        "multi_modal": "null"
      },
      "relevance_score": 0.57721566490153
    }
  ]
}

Changes

No recorded changes to this endpoint across all 1 revision of this API.