HTTP/1.1 402 PAYMENT REQUIRED · Agentic Finance (AIFI) · x402 + MPP dual-stack 500+ tools · 12 rails · 0% seller fee
Agent402 / tools / v1-rerank

Rerank (Cohere-compatible)

$0.002 per call · USDC via x402 · POST /v1/rerank

Rerank documents against a query over x402 - the Cohere /rerank wire ({query, documents[], top_n} -> results with relevance_score), served by cohere/rerank-v3.5, $0.002 per call in USDC, no API key, no signup. Up to 50 documents (1,600 chars each, 40k total) and a 500-char query per call. Deterministic, so a byte-identical repeat within 10 minutes is served FREE from cache (X-Cache: hit; opt out with cache:false). The retrieval companion to /v1/embeddings - embed and recall, then rerank the top candidates.

TRY IN PLAYGROUND →

Input

FieldTypeDescription
query *stringThe search query (max 500 chars)
documents *arrayDocuments to rank (1-50 strings, 1,600 chars each, 40k total)
top_nintegerOptional - return only the top N results
cachebooleanOptional - false disables the default-on response cache

Example output

{
  "id": "gen-rerank-…",
  "model": "rerank-v3.5",
  "results": [
    {
      "index": 0,
      "relevance_score": 0.89,
      "document": {
        "text": "Paris is the capital of France."
      }
    },
    {
      "index": 1,
      "relevance_score": 0.15,
      "document": {
        "text": "Berlin is the capital of Germany."
      }
    }
  ],
  "usage": {
    "search_units": 1
  }
}

Try it - see the 402 challenge (free)

curl -i -X POST https://agent402.tools/v1/rerank \
  -H "Content-Type: application/json" \
  -d '{"query":"What is the capital of France?","documents":["Paris is the capital of France.","Berlin is the capital of Germany.","Madrid is in Spain."],"top_n":2}'

The response is HTTP 402 Payment Required with exact payment requirements. Any x402 v2 client pays automatically and retries:

Paid call (JavaScript agent)

import { wrapFetchWithPayment } from "@x402/fetch";
import { x402Client } from "@x402/core/client";
import { registerExactEvmScheme } from "@x402/evm/exact/client";
import { privateKeyToAccount } from "viem/accounts";

const client = new x402Client();
registerExactEvmScheme(client, { signer: privateKeyToAccount(KEY) });
const payFetch = wrapFetchWithPayment(fetch, client);

const res = await payFetch("https://agent402.tools/v1/rerank", {
  method: "POST",
  headers: { "Content-Type": "application/json" },
  body: JSON.stringify({
    "query": "What is the capital of France?",
    "documents": [
      "Paris is the capital of France.",
      "Berlin is the capital of Germany.",
      "Madrid is in Spain."
    ],
    "top_n": 2
  }),
});
Wallet-only. This tool reaches the network/browser/storage, so it is paid in USDC via x402 (no proof-of-work tier).

Related tools

Chat completions - nano tier

$0.003 · POST /v1/nano/chat/completions

OpenAI-compatible chat completions, nano tier: gpt-4.1-nano, gpt-5-nano, gemini flash-lite, small llama/ministral/qwen, …

try in playground →

Chat completions - auto tier (eval-ranked routing)

$0.01 · POST /v1/auto/chat/completions

OpenAI-compatible chat completions with server-side model choice: omit "model" (or send "auto") and the gateway routes t…

try in playground →

Grounded chat (web search, OpenAI-compatible)

$0.03 · POST /v1/grounded/chat/completions

OpenAI-compatible chat completions GROUNDED in a live web search on every call: the gateway runs an Exa search (up to 5 …

try in playground →