Rerank

Submit a rerank request

Changed on

Submits a rerank request to the rerank router

post/rerank

Request

  • Base URL
    https://openrouter.ai/api/v1
  • Auth
    HTTP bearer

Request body

object required

Rerank request input

documents, union[] required

The list of documents to rerank. Documents may be plain strings, or structured objects with text and/or image for multimodal models.

model, string required

The rerank model to use

provider, intersection

Provider routing preferences for the request.

query, string required

The search query to rerank documents against

session_id, string

A unique identifier for grouping related requests (e.g., a conversation or agent workflow). Used for observability grouping in Broadcast and private logging; never sent to the provider. If provided in both the request body and the x-session-id header, the body value takes precedence. Maximum of 256 characters.

top_n, integer

Number of most relevant documents to return

trace, TraceConfig

Metadata for observability and tracing. Known keys (trace_id, trace_name, span_name, generation_name, parent_span_id) have special handling. Additional keys are passed through as custom metadata to configured broadcast destinations.

user, string

A unique identifier representing your end-user. Forwarded to Broadcast and private logging as the end-user id; never sent to the provider.

Example request

{
  "documents": [
    "Paris is the capital of France.",
    "Berlin is the capital of Germany."
  ],
  "model": "cohere/rerank-v3.5",
  "query": "What is the capital of France?",
  "top_n": 3
}

Response

Rerank response

object required

Rerank response containing ranked results

id, string

Unique identifier for the rerank response (ORID format)

model, string required

The model used for reranking

provider, string

The provider that served the rerank request

results, object[] required

List of rerank results sorted by relevance

usage, object

Usage statistics

Example response

{
  "id": "gen-rerank-1234567890-abc",
  "model": "cohere/rerank-v3.5",
  "results": [
    {
      "document": {
        "text": "Paris is the capital of France."
      },
      "index": 0,
      "relevance_score": 0.98
    }
  ],
  "usage": {
    "search_units": 1,
    "total_tokens": 150
  }
}

Changes

    • info

      added the new optional request property provider/allOf[#/components/schemas/ProviderPreferences]/options/celeris

    • info

      added the new Celeris enum value to the request property provider/allOf[#/components/schemas/ProviderPreferences]/ignore/items/anyOf[#/components/schemas/ProviderName]

    • info

      added the new Celeris enum value to the request property provider/allOf[#/components/schemas/ProviderPreferences]/only/items/anyOf[#/components/schemas/ProviderName]

    1 more change in this revision