Rerank documents by relevance: reranker for RAG

$0.002 per call · failed calls are never charged · no account or API key needed

Order up to 50 documents by how well each answers a query, with a relevance score from 0 to 1 (BAAI bge-reranker-base, a cross-encoder). Send documents as a JSON array or one per line; each is read up to 2,000 characters, 40,000 in all. Returns the original index, score and text, best first; top_n keeps only the best. Also available in the Cohere-style shape at /v1/rerank. Use to pick what a model reads after search or vector retrieval.

Run it free (25 free calls) Buy credits by card (from $5) Example result (JSON)

Try it with your own inputs

What the documents should answer (up to 2,000 characters)
Up to 50 documents: a JSON array of strings, or one per line

Uses one of your 25 free calls. Nothing is charged, and a call that fails is not counted.

Inputs

NameTypeDescription
query (required)stringWhat the documents should answer (up to 2,000 characters)
documents (required)stringUp to 50 documents: a JSON array of strings, or one per line
top_nstringKeep only the best N results (default all)

Request

Over HTTP, with a card key from /credits:

curl -H "Authorization: Bearer adt_…" "https://agent-data-tools.revmesh2074.workers.dev/ai/rerank?query=What%20is%20the%20capital%20of%20France%3F&documents=%5B%22France%20has%20hundreds%20of%20cheeses.%22%2C%22Berlin%20is%20the%20capital%20of%20Germany.%22%2C%22Paris%20is%20the%20capital%20and%20largest%20city%20of%20France.%22%5D"

Or one of your 25 free calls, no key:

curl "https://agent-data-tools.revmesh2074.workers.dev/ai/rerank?query=What%20is%20the%20capital%20of%20France%3F&documents=%5B%22France%20has%20hundreds%20of%20cheeses.%22%2C%22Berlin%20is%20the%20capital%20of%20Germany.%22%2C%22Paris%20is%20the%20capital%20and%20largest%20city%20of%20France.%22%5D&trial=1"

Without a key, the same URL answers 402 Payment Required with x402 and MPP terms, so an agent with a wallet pays per call in USDC (Base, Polygon, Arbitrum or Solana over x402; Base or Tempo over MPP) and retries.

Example result

{
  "query": "What is the capital of France?",
  "results": [
    {
      "index": 2,
      "relevance_score": 0.999785,
      "document": "Paris is the capital and largest city of France."
    },
    {
      "index": 1,
      "relevance_score": 0.025102,
      "document": "Berlin is the capital of Germany."
    }
  ],
  "documents": 3,
  "clippedDocuments": 0,
  "model": "@cf/baai/bge-reranker-base"
}

From an AI agent (MCP)

Add the MCP server to Claude, Cursor or any MCP client. This tool is ai_rerank, and the first 25 successful calls are free:

https://agent-data-tools.revmesh2074.workers.dev/mcp

Related tools