v1

latestOpenAPI 3.1.0MIT2026-07-13174391.2 KB

Rerank search results by relevance

post/v1/rerank

Request body

modelstring required

ID of the model to use for reranking

querystring required

The search query to compare documents against

documentsstring[] required

An array of document strings to be reranked. Alternatively, use embedding_ids instead.

embedding_idsstring[]

An array of embedding IDs to rerank (alternative to documents). Remote content storage must be enabled.

top_ninteger

Number of top results to return

Example request

{
  "model": "morph-rerank-v4",
  "query": "How to implement JWT authentication in Express",
  "documents": [
    "This Express.js middleware provides authentication using JWT tokens and protects routes.",
    "Express.js is a popular web framework for Node.js applications."
  ],
  "embedding_ids": [
    "emb_123456789",
    "emb_987654321"
  ],
  "top_n": 5
}

Response

Reranking response

idstring required

Unique identifier for the rerank request

modelstring required

ID of the model used

Example response

{
  "id": "rerank-16aac89e81dc4169b7bc7cab0672f2d9",
  "model": "morph-rerank-v4",
  "usage": {
    "total_tokens": 18
  },
  "results": [
    {
      "document": {
        "text": "This Express.js middleware provides authentication using JWT tokens and protects routes."
      },
      "relevance_score": 0.92
    }
  ]
}