For the complete documentation index, see llms.txt. This page is also available as Markdown.

Rerank

Create Rerank

post

Rerank documents by relevance to a query.

Billing: a model priced per request (unit: request) is charged per search unit the provider reports, or for one unit when it reports none. A model priced per token is charged on the input tokens the provider reports.

usage carries what the gateway metered: the provider's tokens, the search units billed when the model is priced per request, and, when the request was priced, cost_usd and pricing_source as a completion's usage does. meta is the provider's own billing report, unchanged.

Authentication modes:

  • Master key + user field: Use specified user (must exist)

  • API key + user field: Use specified user (must exist)

  • API key without user field: Use the shared "default" user

Authorizations
Otari-KeystringRequired

Enter your API key here (sent as Otari-Key header).

Body

Rerank request.

documentsstring[] · min: 1Required

List of document strings to rerank

max_tokens_per_docinteger · nullableOptional

Per-document truncation limit

modelstringRequired

Provider-prefixed model ID, e.g. 'cohere:rerank-v3.5'

querystringRequired

The search query to rerank documents against

top_ninteger · nullableOptional

Maximum number of results to return

userstring · nullableOptional

User ID for usage attribution

Responses
200

Successful Response

application/json

Documents ordered by relevance, with the gateway's metered usage.

idstring · nullableOptional

Provider-assigned response ID

modelstring · nullableOptional

The model that served the request

post/api/v1/rerank
POST /api/v1/rerank HTTP/1.1
Otari-Key: YOUR_API_KEY
Content-Type: application/json
Accept: */*
Content-Length: 99

{
  "documents": [
    "text"
  ],
  "max_tokens_per_doc": 1,
  "model": "text",
  "query": "text",
  "top_n": 1,
  "user": "text"
}
{
  "id": "text",
  "meta": {
    "billed_units": {
      "ANY_ADDITIONAL_PROPERTY": 1
    },
    "tokens": {
      "ANY_ADDITIONAL_PROPERTY": 1
    }
  },
  "model": "text",
  "results": [
    {
      "index": 1,
      "relevance_score": 1
    }
  ],
  "usage": {
    "cost_usd": "text",
    "pricing_source": "text",
    "search_units": 1,
    "total_tokens": 1
  }
}

Last updated

Was this helpful?