Cohere Integration

Rerank documents (Cohere format)

Reranks a list of documents against a query using Cohere's v2 Rerank API. The request body matches Cohere's native format.

POST
/cohere/v2/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

Cohere rerank model identifier (e.g. rerank-english-v3.0).

querystring

Query string to rank documents against.

documentsarray<string | object>

Documents to rerank. Strings or objects with a text field.

top_n?integer

Return only the top N reranked results.

return_documents?boolean

Include the original document text in the response.

max_tokens_per_doc?integer

Truncate each document to this token limit before ranking.

[key: string]any

Response Body

curl -X POST "https://loading/{AI_GATEWAY_URL}/cohere/v2/rerank" \  -H "Content-Type: application/json" \  -d '{    "model": "string",    "query": "string",    "documents": [      "string"    ]  }'
{
  "id": "string",
  "results": [
    {
      "index": 0,
      "relevance_score": 0,
      "document": {}
    }
  ],
  "meta": {}
}
{
  "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