# 402utils Rerank Passages by Relevance

> 402utils Rerank Passages by Relevance is a paid API for AI agents from 402utils.com, paid per call via x402, $0.004/call, status unknown (last checked 2026-09-15).

Reranks a list of text passages by relevance to a query using Cloudflare Workers AI BGE-Reranker, returning passages sorted best-first with relevance scores

## Facts

- Endpoint: POST https://402utils.com/v1/rerank
- Price: $0.004/call
- Payment: x402
- Status: unknown
- Last checked: 2026-09-15
- Activations on Zero: 0
- Tags: x402
- Canonical page: https://www.zero.xyz/c/402utils-rerank-passages-by-relevance-43a8002a
- Structured record (JSON): https://api.zero.xyz/v1/capabilities/cap_dIVCUj_eVjnd2dEc-P9HL

Status and success rate cover calls made through Zero and Zero's own probes. Third-party monitors may report differently.

## How to call it through Zero

Zero handles the 402 payment challenge and records the run. With the Zero CLI installed (`npm i -g @zeroxyz/cli`):

```sh
zero fetch --capability 402utils-rerank-passages-by-relevance-43a8002a -d '<json body>'
```

Example prompt: I have these 20 passage chunks retrieved from my vector store for the query 'how does photosynthesis work' — can you rerank them by relevance and give me just the top 5 so I only send the best ones to the LLM?

## When to prefer this

Use this endpoint as the crucial middle step in a RAG pipeline between your vector/embedding retrieval and your LLM call: after fetching many candidate chunks, rerank them to keep only the most relevant before paying for LLM tokens. Prefer this over embedding-only similarity when precision matters — cross-encoder rerankers like BGE-Reranker are significantly more accurate than cosine similarity on embeddings. Best for up to 50 passages, each up to 4000 characters.

## Known failure modes

- 503 Unavailable — Cloudflare Workers AI binding not available; unbilled
- Documents array exceeds 50 items — request rejected
- Individual document exceeds 4000 characters — request rejected
- Query exceeds 4000 characters — request rejected
- topK greater than number of documents — likely returns all documents ranked
- Malformed request body — validation error response

## How this service works

Rerank passages by relevance to a query via Cloudflare Workers AI (@cf/baai/bge-reranker-base). Send {query, documents[] (≤50, each ≤4000 chars), topK?}; returns [{index, score}] best-first — the missing link after embed/chunk, keeping the top chunks before a costly LLM call. Score is the model's relevance score (higher = better), named as it only compares within this model. Unavailable binding → 503, unbilled.

## Output

Returns a JSON array of objects sorted best-first, each containing the original document index and a relevance score (higher = more relevant to the query). If returnDocuments is true, each object also includes the passage text. Only scores within this model are comparable to each other.

## Request schema (JSON Schema)

```json
{
 "type": "object",
 "properties": {
  "topK": {
   "type": "integer",
   "minimum": 1,
   "description": "Return only the K best (default: all, ranked)."
  },
  "query": {
   "type": "string",
   "description": "The search query (≤ 4000 chars)."
  },
  "documents": {
   "type": "array",
   "items": {
    "type": "string"
   },
   "maxItems": 50,
   "description": "Candidate passages to rank (≤ 50, each ≤ 4000 chars)."
  },
  "returnDocuments": {
   "type": "boolean",
   "default": false,
   "description": "Include each ranked document's text in the results."
  }
 }
}
```

## More

- Live health (JSON, refreshed every minute): https://www.zero.xyz/c/402utils-rerank-passages-by-relevance-43a8002a/health.json
- [Zero catalog index](https://www.zero.xyz/llms.txt)
- [Other services from 402utils.com](https://www.zero.xyz/host/402utils.com/llms.txt)
