Skip to main content
Connect another OpenAI-compatible inference server to Hivenet Router with the custom engine. Use this integration when your backend is not covered by one of Hivenet Router’s built-in engine types but exposes a compatible chat-completions endpoint.
The custom engine requires both --model and --health-url. It does not discover either value from the backend.

Backend requirements

The backend must expose: The health endpoint can use any path. Pass its complete URL to --health-url. For example:
Hivenet Router forwards the original chat-completion request body and HTTP headers to the backend. It does not translate a proprietary request format into the OpenAI schema.
This page covers language-model agents using the default llm capability. Use the dedicated Infinity integration for the documented embedding and reranking workflow.

Before you start

You need:
  • a running Hivenet Router router
  • an OpenAI-compatible inference backend
  • a health endpoint that returns HTTP 200
  • network access between the agent and router
  • the Hivenet Router agent binary or Docker image
  • the same JWT secret used by the router
  • a model name that clients and the backend can use
The examples use:
Replace these values with addresses and model names from your deployment.

Start your backend

The command depends on the inference server you are using. A generic example might look like:
Because the Hivenet Router agent runs beside the backend, the backend can remain bound to localhost unless another machine must reach it directly. Check the health endpoint:
Hivenet Router considers the backend ready only when this endpoint returns HTTP 200. Test chat completions directly:
Confirm this request works before starting the Hivenet Router agent.

Choose the model name

The custom engine does not call /v1/models. You must provide the model name explicitly:
Hivenet Router uses this value to:
  • register the agent
  • list the model through GET /v1/models
  • match incoming requests to the agent
  • label routing and observability data
The request body is forwarded without replacing its model field. For the cleanest setup, use the same model name:
  1. in the agent’s --model value
  2. in client requests
  3. in the backend’s public API
If the backend uses another internal identifier, configure an alias or compatibility layer on the backend side.

Prepare the Hivenet Router agent

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 identity:
Place the router’s JWT secret at:
Protect it:

Start the agent

Omit --gpus all when the backend is CPU-only or the agent does not need NVIDIA hardware metrics.The /data mount preserves the agent’s peer identity across container replacement and restarts.
The agent waits until the configured health endpoint returns HTTP 200. If the backend is still starting, the agent continues polling rather than exiting permanently.

Understand the custom settings

You can also add routing tags:

How requests are forwarded

For a non-streaming request, the agent sends:
It forwards the original JSON body and request headers to the backend. For example, a client request to:
is eventually forwarded to:
Backend response headers and response bodies are returned through the agent and router to the client. Backend errors are also passed back through Hivenet Router. Where possible, Hivenet Router classifies common errors such as:
  • invalid parameters
  • context-length limits
  • backend unavailability
  • rate limits
  • general backend failures

Streaming responses

The custom engine supports streaming chat completions when the backend returns an SSE response compatible with the OpenAI API. Send:
The agent forwards response chunks as they arrive rather than buffering the full completion. The backend must provide a valid streaming response. Hivenet Router does not convert a non-streaming backend response into SSE.

Set agent capacity

--capacity controls how many concurrent requests Hivenet Router may assign to the agent. It does not configure the backend’s own scheduler, worker count, queue, or batch size. Choose a value based on:
  • backend concurrency
  • model size
  • available CPU, RAM, or VRAM
  • context length
  • acceptable response time
  • whether other workloads share the machine
Start conservatively and test with representative traffic. When the agent reaches capacity, Hivenet Router considers another matching agent, waits if queueing is configured, or moves through the policy’s fallback chain.
For streaming responses, Hivenet Router releases the agent capacity slot when response headers arrive, while backend generation can continue. Treat --capacity as a routing-admission setting rather than a hard limit on ongoing streams, and verify the custom backend under sustained streaming load.

Verify the connection

On the router, check operational health:
Confirm the model is visible:
Inspect custom agents:
Send a request through Hivenet Router:

Route to custom agents

Match the custom engine in a routing policy:
Add another engine as a fallback:
Custom agents participate in the same policy pipeline as other language-model agents. You can filter them using metadata such as:
  • model
  • engine
  • region
  • organization
  • machine
  • tags
  • GPU model
You can also use universal and hardware signals such as success rate, latency, capacity, GPU pressure, CPU use, and memory use.

Available metrics

The custom integration does not scrape engine-specific metrics from the backend. The following information is still available:

Routing and request metrics

  • routed and failed request counts
  • active requests and declared capacity
  • success and failure history
  • smoothed round-trip time
  • policy and fallback decisions
  • tenant and model labels where configured

Hardware metrics

When available on the agent host:
  • CPU use
  • system memory use
  • GPU utilization
  • VRAM use
  • GPU temperature
  • GPU power
Engine-specific fields such as KV cache utilization, backend queue size, time to first token, and inter-token latency are not populated by the custom integration. View the agent through the router:
Inspect relevant Prometheus metrics:

Troubleshooting

The agent reports that --model is required

The custom engine cannot discover models. Start the agent with:

The agent reports that --health-url is required

Provide the complete health endpoint:
This is separate from --backend-url.

The backend never becomes ready

Test the exact URL passed to --health-url:
The endpoint must return HTTP 200. Redirects, authentication challenges, and other status codes are treated as unhealthy.

Direct requests work, but routed requests fail

Test the exact OpenAI-compatible path:
Common causes include:
  • the backend uses another path
  • the backend expects a proprietary request schema
  • the model name differs
  • the backend requires credentials that are not present in the client request
  • the backend does not support the requested field or streaming mode

The model is visible but requests do not route

Check the model value in all three places:
The agent’s registered model must match the client request. Inspect the routing table:

The agent does not register

Check the logs:
Test connectivity from the agent to the router:
Check that:
  • the router and agent use the same JWT secret
  • the backend health endpoint returns HTTP 200
  • the router’s libp2p interface is reachable
  • the router advertises a libp2p address the agent can reach

Streaming is buffered or incomplete

Test the backend directly with curl -N. Confirm that it returns a streaming content type and flushes chunks as they are generated. Hivenet Router can relay an SSE stream, but it cannot correct buffering introduced by the backend or an intermediate proxy.

Requests time out

The backend HTTP timeout defaults to two minutes. Increase it for longer requests:
For streaming responses, the rolling stream-write timeout is configured separately:
Also check the backend’s own timeout, queue, and concurrency settings.

The peer ID changes after restart

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

Next steps

Chat completions

Review the supported request, response, and streaming behavior.

Routing concepts

Learn how custom agents participate in routing and fallback.

Hardware metrics

Understand the system and GPU signals collected from agent hosts.