Rerank documents by relevance: reranker for RAG
No account. Pay by card from $1 and your key appears right after payment. Get a key by card
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.
Guide: Text embeddings API
Inputs
| Name | Type | Description |
|---|---|---|
query (required) | string | What the documents should answer (up to 2,000 characters) |
documents (required) | string | Up to 50 documents: a JSON array of strings, or one per line |
top_n | string | Keep only the best N results (default all) |
Request
Over HTTP, with a card key from /credits:
curl -H "Authorization: Bearer adt_…" "https://glyphtools.com/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"
Node.js
const r = await fetch("https://glyphtools.com/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", {
headers: { Authorization: "Bearer adt_…" },
});
const data = await r.json(); // 402 until the key is in the header
Python
import requests
r = requests.get("https://glyphtools.com/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", headers={"Authorization": "Bearer adt_…"}, timeout=60)
data = r.json()
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, paid from the first call:
https://glyphtools.com/mcp