Rerank

Rerank documents

Reorders input documents by relevance to a query.

POST
/v1/rerank
AuthorizationBearer <token>

Bearer token authentication. Use your MPilot virtual-key JWT or admin JWT. Virtual keys (prefixed with sk-bf-) can also be passed here.

In: header

modelstring

Model in provider/model format

querystring

Query used to score and reorder documents

Length1 <= length
documentsarray<RerankDocument>

Documents to rerank

Items1 <= items
fallbacks?array<string>

Fallback models in provider/model format

top_n?integer

Maximum number of ranked results to return

Range1 <= value
max_tokens_per_doc?integer

Maximum tokens to consider per document (provider-dependent)

Range1 <= value
priority?integer

Request priority hint (provider-dependent)

return_documents?boolean

Whether to include document content in each result

Response Body

curl -X POST "https://loading/{AI_GATEWAY_URL}/v1/rerank" \  -H "Content-Type: application/json" \  -d '{    "model": "cohere/rerank-v3.5",    "query": "string",    "documents": [      {        "text": "string"      }    ]  }'
{
  "id": "string",
  "results": [
    {
      "index": 0,
      "relevance_score": 0,
      "document": {
        "text": "string",
        "id": "string",
        "meta": {}
      }
    }
  ],
  "model": "string",
  "usage": {
    "prompt_tokens": 0,
    "prompt_tokens_details": {
      "text_tokens": 0,
      "audio_tokens": 0,
      "image_tokens": 0,
      "cached_read_tokens": 0,
      "cached_write_tokens": 0
    },
    "completion_tokens": 0,
    "completion_tokens_details": {
      "text_tokens": 0,
      "accepted_prediction_tokens": 0,
      "audio_tokens": 0,
      "citation_tokens": 0,
      "num_search_queries": 0,
      "reasoning_tokens": 0,
      "image_tokens": 0,
      "rejected_prediction_tokens": 0
    },
    "total_tokens": 0,
    "cost": {
      "input_tokens_cost": 0,
      "output_tokens_cost": 0,
      "reasoning_tokens_cost": 0,
      "citation_tokens_cost": 0,
      "search_queries_cost": 0,
      "request_cost": 0,
      "total_cost": 0
    }
  },
  "extra_fields": {
    "request_type": "string",
    "provider": "openai",
    "model_requested": "string",
    "model_deployment": "string",
    "latency": 0,
    "chunk_index": 0,
    "raw_request": {},
    "raw_response": {},
    "cache_debug": {
      "cache_hit": true,
      "cache_id": "string",
      "hit_type": "string",
      "requested_provider": "string",
      "requested_model": "string",
      "provider_used": "string",
      "model_used": "string",
      "input_tokens": 0,
      "threshold": 0,
      "similarity": 0
    }
  }
}
{
  "event_id": "string",
  "type": "string",
  "is_bifrost_error": true,
  "status_code": 0,
  "error": {
    "type": "string",
    "code": "string",
    "message": "string",
    "param": "string",
    "event_id": "string"
  },
  "extra_fields": {
    "provider": "openai",
    "model_requested": "string",
    "request_type": "string"
  }
}
{
  "event_id": "string",
  "type": "string",
  "is_bifrost_error": true,
  "status_code": 0,
  "error": {
    "type": "string",
    "code": "string",
    "message": "string",
    "param": "string",
    "event_id": "string"
  },
  "extra_fields": {
    "provider": "openai",
    "model_requested": "string",
    "request_type": "string"
  }
}
On this page

On this page

No Headings