Skip to main content
Connect an Infinity server to Hivenet Router for embedding and reranking workloads. Infinity can serve several models from one process. Hivenet Router connects to that process through separate agents, with one agent representing one model and one capability.
The Infinity integration does not support chat completions. Start each agent with either --capability embedding or --capability reranker.

Before you start

You need:
  • a running Hivenet Router router
  • Infinity installed or available as a Docker image
  • one or more embedding or reranking models
  • network access between the agent host and router
  • the Hivenet Router agent binary or Docker image
  • the same JWT secret used by the router
  • an NVIDIA GPU if you want CUDA inference and GPU metrics
The examples use one Infinity process serving two models: They also use:
Replace these values with addresses and models from your deployment.

Start Infinity

Hivenet Router expects Infinity to expose:
Set INFINITY_URL_PREFIX=/v1 so the inference and model endpoints use the paths expected by Hivenet Router.
Start one Infinity process with an embedding model and a reranking model:
The named volume preserves downloaded model data between container replacements.Follow the startup logs:
For CPU inference, use an appropriate CPU image and remove:
Adjust --device and --dtype for the selected Infinity image and hardware.
Wait until Infinity is ready:
A ready server returns HTTP status 200. List the exposed models:
The response should include:

Understand model names

--model-id tells Infinity which model to load. --served-model-name gives that model the public name exposed through Infinity’s API. For example:
The Hivenet Router agent and API clients use:
They do not need to use the original Hugging Face model ID.
The order of repeated --served-model-name values must match the order of the corresponding --model-id values.

Prepare the Hivenet Router agents

You need two agents for this example:
  • one embedding agent for bge-m3
  • one reranking agent for bge-reranker-large
Both agents connect to the same Infinity process.
From the Hivenet Router repository, build the agent image if you have not already done so:
Create a directory for the shared secret and persistent identities:
Place the router’s JWT secret at:
Protect it:

Start the embedding agent

The embedding agent represents bge-m3 and accepts requests sent to:
For CPU-only inference, omit:

Start the reranking agent

The reranking agent represents bge-reranker-large and accepts requests sent to:
When several agents run on the same host, each one needs:
  • a separate --identity-path
  • a unique process or container name
The agents can share the same --backend-url. They initiate their own connections to the router, so you do not need a separate inbound agent port for each process.

Understand capabilities

Hivenet Router uses the agent capability to separate different kinds of inference traffic. The router filters agents by capability before applying the rest of the routing policy. An embedding request cannot be sent to a reranking agent, even if both agents use Infinity or share the same backend process. Do not leave the default capability of llm on an Infinity agent. Infinity rejects chat-completion requests, and Hivenet Router reports a structured invalid-request error.

Set agent capacity

--capacity controls how many concurrent requests Hivenet Router may assign to an agent. It does not change Infinity’s batching or scheduler settings. The original deployment examples use: Treat these as starting points. The appropriate value depends on:
  • model size
  • accelerator and available memory
  • input length
  • batch size
  • number of models sharing the Infinity process
  • acceptable latency
Because both agents share one Infinity process and one set of hardware resources, their capacities are not independent physical limits. Test the combined workload before raising either value.
For streaming-capable workloads, Hivenet Router releases an agent capacity slot when response headers arrive, while backend work can continue. Infinity embeddings and reranking are normally non-streaming, but the same --capacity value remains a routing-admission setting rather than a direct backend scheduler limit.

Verify both agents

On the router, check health:
Inspect the Infinity agents:
List the models exposed to clients:
You should see one embedding model and one reranking model.

Test embeddings

Send a batch embedding request:
A successful response contains one vector for each input:
The vector above is shortened for readability.

Test reranking

Send a reranking request:
The response orders results by relevance score:
The score above is illustrative. Actual values depend on the model and input. The index value points to the document’s position in the original input array.

Routing behavior

Hivenet Router routes embedding and reranking requests through the same policy pipeline used for language-model requests:
  1. Filter by model.
  2. Filter by capability.
  3. Apply static policy matches.
  4. Apply health, capacity, and dynamic gates.
  5. Rank the remaining agents.
  6. Continue through configured fallback steps if needed.
A policy can target Infinity agents:
Capability filtering is automatic. You do not need a policy rule to prevent embedding traffic from reaching reranking agents.

Observability

The Infinity integration does not currently scrape engine-specific metrics from the Infinity backend. Hivenet Router still exposes:
  • registered agent state
  • capability and model metadata
  • routed and failed request counters
  • active requests and capacity utilization
  • request success rate
  • smoothed round-trip time
  • CPU and memory metrics
  • NVIDIA GPU metrics when NVML is available
  • audit records when audit logging is enabled
Embedding request rate:
Reranking request rate:
Smoothed round-trip time:
Inspect all Infinity-related metrics:

Troubleshooting

/v1/models returns 404

Confirm that Infinity was started with:
For Docker, inspect the container environment:
Without the prefix, Infinity serves its API at different paths from those expected by Hivenet Router. Restart Infinity after changing the setting.

An agent cannot discover its model

Check Infinity:
List model IDs:
The returned ID must match the agent’s --model value exactly.

The wrong model name is exposed

Check the order of:
Each served name corresponds to the model ID in the same position. Restart Infinity after changing the mapping.

Embedding requests are routed incorrectly

Confirm that the agent uses:
Inspect the routing table:

Reranking requests are routed incorrectly

Confirm that the agent uses:
The accepted capability value is reranker, while the HTTP endpoint is:

An agent does not register

Check its logs:
Test connectivity from the agent host:
Check that:
  • the router and agents use the same JWT secret
  • the agent host can reach the router’s gRPC and libp2p ports
  • each agent has a unique identity path
  • Infinity is healthy
  • the selected model is listed by /v1/models

A peer ID changes after restart

Make sure each --identity-path points to persistent storage. For Docker:
For bare metal:

Requests time out

The agent’s backend HTTP timeout defaults to two minutes. Increase it when large batches need more time:
Also review:
  • embedding or document batch size
  • input length
  • declared agent capacity
  • Infinity batch size
  • whether both models compete for the same GPU memory

GPU metrics are missing

Check the host:
For Docker, confirm that each agent received GPU access:
The agents continue to operate without NVML. They report CPU and memory metrics but omit GPU measurements.

Next steps

Custom engine agent

Connect another OpenAI-compatible backend to Hivenet Router.

Embeddings

Review the embedding request and response format.

Reranking

Review reranking fields, examples, and response ordering.