Rerank

POST /v1/rerank (and /v2/rerank) take Cohere's request and answer results[]. The model is <provider>/<model>, for example cohere/rerank-v3.5 or openrouter/cohere/rerank-4-fast.

cURLcurl
1curl https://api.aile.sh/v1/rerank \
2-H "Authorization: Bearer $AILE_KEY" \
3-H "Content-Type: application/json" \
4-d '{
5 "model": "cohere/rerank-v3.5",
6 "query": "capital of France",
7 "documents": ["Paris is in France.", "Berlin is in Germany."],
8 "top_n": 1
9}'

Billing

  • One search is one query over up to 100 documents: ceil(documents / 100) searches.
  • The count is known before the call, so the hold is the bill.
  • Documents are text: strings, or objects ranked on their text field. An object without text is ranked on its JSON, or on just its rank_fields when you send them. Image documents are a 400. Each model's document limit applies.
  • Each result carries document: {text} unless you send return_documents: false. The response also has object: "list" and a Voyage-shaped data[] whose document is the plain string.
  • A response with no ranking, or one that does not match the documents sent, is a 502 and is not charged.
  • A provider refusal you can fix (400, 404, 413, 422 …) passes through. One about the lender's account is a 502 saying you were not charged. A 502 or 504 arrives as 503 with the real code in x-aile-status.
  • A key's pins and the routing headers choose the lender here too. x-aile-provider must match the model's prefix, and x-aile-max-price does not apply to a per-search price.
  • Where the deployment enables it, rerank also takes keyless x402.