Skip to main content
Connect a vLLM inference server to Hivenet Router by running an agent beside the backend. The agent discovers the model served by vLLM, registers it with the router, forwards requests, and reports engine and hardware metrics that Hivenet Router can use for routing and observability.
Each Hivenet Router agent registers one model. If a backend exposes several models, run a separate agent for each model and use --model to select the model that agent represents.

Before you start

You need:
  • a running Hivenet Router router
  • an NVIDIA GPU with CUDA support
  • network access between the agent host and the router
  • access to the model you want to serve
  • either Docker or a Python environment supported by vLLM
  • the Hivenet Router agent binary or Docker image
  • the same JWT secret used by the router
The examples use:
Replace these values with addresses and model names from your deployment.

Start vLLM

Start vLLM with host networking:
If the model requires authentication or license acceptance, provide the required credentials through your normal secrets-management process.Follow the startup logs:
Wait for the model to load, then check the backend:
A ready vLLM server returns HTTP status 200. List the models reported by vLLM:
The model ID returned here is the value clients must use when sending requests through Hivenet Router.
Hivenet Router forwards each request’s ID to vLLM in the X-Request-ID header, and vLLM uses it as the request ID in its logs, so the router’s and vLLM’s logs show the same ID. The router generates a new ID for every request, and a retry of the same request gets the ID followed by -2, -3 and so on, so vLLM never receives the same ID twice. When a retry’s response comes back, the client sees the router’s request ID in X-Request-ID and the retry’s ID, for example <id>-2, in X-Upstream-Request-ID.

Prepare the Hivenet Router agent

Pull the prebuilt agent image from the GitHub Container Registry:
Use :nightly if you want the moving pre-release tag built from the latest commit on main. Immutable :nightly-<shortsha> tags are also published.To build a custom image from source instead, clone the Hivenet Router repository and run:
Create a directory for the shared secret and persistent agent identity:
Place the router’s JWT secret at:
Protect it:

Start the agent

The /app/data mount preserves the agent’s peer identity across container replacement and restarts.The agent container receives GPU access so it can collect NVIDIA hardware metrics. Inference still runs in the separate vLLM process or container.
The agent waits for vLLM to become healthy before registering. If vLLM is still loading, the agent continues polling rather than exiting permanently.

Understand the agent settings

You can also add comma-separated routing tags:
Tags can be matched in routing policies.

Select the model

The agent can discover the model automatically or use an explicit model name.

Automatic discovery

When --model is omitted, the agent requests:
It registers the first model in the response. For a vLLM server exposing one model, automatic discovery is usually sufficient.

Explicit model selection

Use --model when you want to pin the agent to a specific model:
The explicit value overrides automatic discovery.
The model name registered by the agent must match the model name clients send to Hivenet Router.

Use a vLLM server that requires an API key

If you start vLLM with --api-key, it rejects every /v1/* request that lacks Authorization: Bearer <key>, including the model discovery request the agent sends before any client traffic exists. Give the agent the same key:
When a backend API key is set, the agent sends Authorization: Bearer <key> on every request to the backend: readiness and health checks, model discovery, metrics scrapes, and inference. The client’s router API key never reaches vLLM, with or without a backend key: the agent removes the client’s credentials before every request. When both are provided, --backend-api-key-file wins.
The agent never forwards the client’s router credentials to the backend: Authorization, X-Api-Key, Cookie and Proxy-Authorization are removed first. If the backend requires authentication, set a backend API key.
The setting is not specific to vLLM. It works the same way for every engine and any OpenAI-compatible backend that expects a bearer key. See Backend API key.

Connect multiple models

Each agent registers as an independent peer and represents one model. If one backend exposes multiple models, start one agent process for each model:
Start the second agent with a different model and identity:
When several agents run on the same host, each one needs a separate --identity-path so every process keeps a distinct peer identity.

Set agent capacity

Set --capacity to the number of concurrent requests the backend can safely accept. For vLLM, start by matching it to --max-num-seqs:
You may set the Hivenet Router capacity slightly lower to preserve headroom:
When an agent reaches its declared capacity, the router stops assigning new requests to it and considers other matching agents or configured fallback steps. Capacity does not change vLLM’s own scheduler limit. It tells Hivenet Router how much work the agent is prepared to accept.
For streaming responses, Hivenet Router holds the agent capacity slot until the stream fully drains, whether the stream ends normally or the client disconnects. --capacity therefore limits concurrent generations routed through Hivenet Router, including ongoing streams. Verify vLLM concurrency under sustained streaming load before raising it.

Verify the connection

On the router, check agent health:
List the models available to clients:
Inspect detailed routing state:
Send an inference request:

vLLM metrics

The agent scrapes vLLM’s /metrics endpoint every 500 milliseconds by default. It sends the resulting engine data to the router, which exposes it through the router’s Prometheus endpoint. The agent does not expose a separate Prometheus port. View all engine metrics on the router:
Useful exported metrics include:
View live values through the routing table:

Use vLLM metrics in routing policies

You can exclude agents whose KV cache is under pressure:
Or exclude agents with queued work:
When a metric is unavailable for an agent, Hivenet Router skips that gate for the agent rather than excluding it. See Policy YAML reference for the full policy schema.

Troubleshooting

Check vLLM health:
Check model discovery:
The agent waits and retries if vLLM is healthy but no model is available yet.
Automatic discovery selects the first model returned by /v1/models.Pin the correct one:
Restart the agent after changing the setting.
Check the agent logs:
Confirm connectivity:
Check that the router and agent use the same JWT secret.
Reduce the amount of work Hivenet Router assigns to the agent:
Or reduce vLLM’s scheduler limit:
You can also use a routing gate to stop selecting the agent above a chosen threshold.
Rising preemptions indicate that vLLM is evicting in-flight KV-cache data under memory pressure.Reduce:
  • --capacity on the Hivenet Router agent
  • --max-num-seqs on vLLM
  • model context or batch pressure, where appropriate for your workload
The agent’s backend HTTP timeout defaults to two minutes.Increase it for longer requests:
Make sure --identity-path points to persistent storage.For Docker, confirm the volume is mounted:
For bare metal:
Check vLLM’s metrics endpoint:
Check the agent logs for scrape errors.Metrics are scraped in the background. A scrape failure does not stop the agent from forwarding requests.

Next steps

Ollama agent

Connect an Ollama backend for local or edge inference.

Routing concepts

Learn how Hivenet Router filters and ranks matching agents.

Engine metrics

Understand the metrics collected from vLLM and other engines.