Skip to main content
Send a query and a set of candidate documents to a reranking model, then receive the documents ordered by relevance. Hivenet Router routes these requests to agents registered with the reranker capability.
Infinity is the documented reranking backend. Other engine types can register as rerankers when their backend exposes a compatible POST /v1/rerank endpoint. Ollama agents cannot use the reranker capability.

How reranking requests are routed

For each request, Hivenet Router:
  1. authenticates the client when API authentication is enabled
  2. applies the configured request-rate quota
  3. reads and validates the top-level model field
  4. checks that the API key may use that model
  5. filters for agents registered with the reranker capability
  6. applies routing policies and capacity checks
  7. forwards the original request to POST /v1/rerank on the selected backend
  8. returns the backend response to the client
The selected backend validates the query, documents, result count, and any optional reranking fields.

Request headers

Request body

A typical request contains:
Hivenet Router validates the model field. The backend validates the other fields. The model name must:
  • match a model registered by a reranking agent
  • be allowed by the caller’s API key when model restrictions are enabled
  • contain no more than 256 characters

Request-body size

Hivenet Router limits /v1/* request bodies to 10485760 bytes, or 10 MiB, by default. The complete query and document array count toward this limit. Requests above the configured limit receive HTTP 413 before routing. Configure the limit with HIVENET_ROUTER_MAX_REQUEST_BYTES, or set it to 0 to disable the built-in check. A reverse proxy or ingress may enforce a smaller limit. Reduce the number or size of documents when a request receives 413. Do not depend on a particular JSON error body for this early rejection.

Basic request

With API authentication enabled:

Response

A successful response resembles:
The exact fields depend on the backend. Hivenet Router returns the successful response without changing result scores or ordering.
Use the index field to recover the original document. Do not assume that document will contain the text.

Use Python

With authentication:

Use reranking in a search pipeline

Reranking normally follows a broader retrieval step. A search system might first retrieve 50 approximate matches from a vector database, then ask a reranker to select the 10 most relevant documents.
This preserves the metadata held by the search system while using the reranker’s indices and scores to reorder the candidates.

Additional request fields

Hivenet Router forwards the original JSON request to the backend. You can include additional fields supported by the selected reranking service, but Hivenet Router does not interpret or normalize them. For example:
Whether return_documents or another optional field works depends entirely on the backend. Unsupported fields may be ignored or rejected.

No streaming support

Reranking requests are synchronous. Hivenet Router waits for the selected backend to score the documents and return the complete result set. The endpoint does not use server-sent events. For large candidate sets, keep the batch within the backend’s limits and configure an appropriate request timeout.

Authentication and model access

When API authentication is enabled, send:
An API key can restrict access to specific models. A request for a model outside the key’s allowlist returns HTTP 403:
When authentication is disabled, no authorization header is required.

Quotas

Reranking requests participate in request-rate quota enforcement. When a finite request quota is configured, responses may include:
When the request-rate quota is exhausted, Hivenet Router returns HTTP 429.
The current reranking path does not charge query or document tokens against the daily token quota. Successful reranking requests are recorded with zero input and output tokens for quota accounting.Reranking requests are also exempt from the LLM admission gates, including per-request token caps, KV-occupancy budgets, and serverless token rates. These gates model KV-cache-bound generation. Request-rate, body-size, and agent-concurrency limits still protect this path.

Routing policies

Reranking agents use the same routing pipeline as other Hivenet Router workloads. For example:
Capability filtering happens automatically before policy ranking. A reranking request cannot be routed to an agent registered as llm or embedding. Fallback chains can route across several compatible reranking agents that expose the same model.

Discover reranking models

List the reranking models available through the router:
Inspect registered reranking agents:
The administration endpoint may require separate credentials depending on the router’s admin-auth configuration.

Supported agent configurations

Start the agent with:
Hivenet Router accepts the reranker capability with:
  • Infinity
  • vLLM
  • SGLang
  • llama.cpp
  • custom engines
The selected backend must expose:
Ollama does not expose the required reranking endpoint. Hivenet Router rejects an agent started with both --engine ollama and --capability reranker.
For the documented Infinity setup, see Infinity agent.

Error responses

Router errors use this envelope:
Backend errors use:
Common responses include: See Error codes for the complete reference.

Troubleshooting

The model is not found

List available reranking models:
Check that:
  • the agent uses --capability reranker
  • the requested model matches the registered model exactly
  • the agent is healthy
  • the API key may access the model

The request reaches the wrong capability

Inspect the agent registration:
The capability must be:

The backend rejects the request

Test it directly:
A backend may reject:
  • an empty query
  • an empty document list
  • unsupported document formats
  • too many documents
  • documents above the model’s token limit
  • an invalid top_n
  • unsupported optional fields

The response contains document: null

This is expected for backends that do not return document text by default. Use each result’s index to retrieve the original document from the input array.

Results do not contain every document

Check top_n. For example:
returns at most two results, even when the request contains more documents. When top_n is omitted, the documented Infinity behavior is to return all ranked documents.

Requests time out

Reduce the number or size of candidate documents, or increase the agent’s backend timeout:
Also check:
  • backend model loading state
  • declared agent capacity
  • accelerator memory
  • competing embedding or reranking traffic
  • backend batch configuration

The request is rate-limited

Check:
Review the API key’s request-rate quota and any per-model quota configuration.

Next steps

Models

Discover available models, capabilities, engines, and healthy capacity.

Infinity agent

Configure embedding and reranking models through Infinity.

Routing concepts

Learn how reranking agents are filtered, ranked, and used in fallback chains.