Skip to main content
Amazon Bedrock supports reranking documents using the Amazon Rerank model. Portkey provides a standardized interface for reranking through the unified /v1/rerank endpoint.

Reranking Documents

curl https://api.portkey.ai/v1/rerank \
  -H "Content-Type: application/json" \
  -H "x-portkey-api-key: $PORTKEY_API_KEY" \
  -d '{
    "model": "@bedrock-prod/arn:aws:bedrock:us-east-1::foundation-model/cohere.rerank-v3-5:0",
    "query": "What is the capital of the United States?",
    "documents": [
      "Carson City is the capital city of the American state of Nevada.",
      "The Commonwealth of the Northern Mariana Islands is a group of islands in the Pacific Ocean. Its capital is Saipan.",
      "Washington, D.C. (also known as simply Washington or D.C., and officially as the District of Columbia) is the capital of the United States. It is a federal district.",
      "Capital punishment (the death penalty) has existed in the United States since beforethe United States was a country. As of 2017, capital punishment is legal in 30 of the 50 states."
    ],
    "top_n": 3
  }'

Supported Models

ModelModel ID
Amazon Rerankamazon.rerank-v1:0

Request Parameters

ParameterTypeRequiredDescription
modelstringYesThe reranking model to use
querystringYesThe query to use for reranking
documentsarrayYesList of documents to rerank
top_nintegerNoNumber of top results to return

Response Format

The response follows the unified Portkey rerank response format:
{
  "object": "list",
  "model": "arn:aws:bedrock:us-east-1::foundation-model/cohere.rerank-v3-5:0",
  "results": [
    {
      "index": 2,
      "relevance_score": 0.95
    },
    {
      "index": 0,
      "relevance_score": 0.45
    }
  ],
  "usage": {
    "total_tokens": 150
  }
}