Before you start
You need:- a running Hivenet Router router
- a GGUF model file
- llama.cpp built locally or available as a Docker image
- 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 acceleration and GPU metrics
Start llama.cpp
Use the-a option to give the model a stable alias. The alias becomes the model name registered with Hivenet Router and used by API clients.
Start llama.cpp with --metrics if you want Hivenet Router to collect cache, queue, latency, and throughput metrics.
- Docker
- Bare metal
Place the GGUF file in a local model directory, such as:Start the server:Follow the startup logs:For CPU-only inference, omit:
200.
List the model exposed by its OpenAI-compatible API:
Choose a stable model name
The alias passed with-a determines the model name returned by llama.cpp.
Using an explicit alias makes client configuration and routing policies less dependent on the model filename.
Changing the alias changes the model name seen by Hivenet Router. Clients and routing policies must use the new value.
Prepare the Hivenet Router agent
- Docker
- Bare metal
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
- Docker
- Bare metal
/data mount preserves the agent’s peer identity across container replacement and restarts.Understand the agent settings
You can also add routing tags:
Model discovery
When--model is omitted, the agent requests:
Set agent capacity
--capacity limits how many concurrent requests Hivenet Router may assign to the agent.
It does not change llama.cpp’s own parallelism, slot count, context allocation, or batch configuration.
Conservative starting values from the original deployment guidance are:
Treat these as starting points rather than universal limits. Test with your model, quantization, context size, and hardware.
When the agent reaches its declared capacity, Hivenet Router considers another matching agent or a configured fallback step.
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 llama.cpp concurrency under sustained streaming load.Verify the connection
On the router, check agent health:llama.cpp metrics
The agent scrapes llama.cpp’s/metrics endpoint every 500 milliseconds by default.
Start llama.cpp with --metrics to make this data available. Metrics are sent to the router and re-exported through its Prometheus endpoint. The agent does not expose a separate Prometheus port.
llama.cpp does not use the preemption mechanism measured for vLLM, so Hivenet Router does not populate a preemption metric for this engine.
View all engine metrics through the router:
Use llama.cpp metrics in routing policies
Exclude agents whose KV cache is under pressure:Tune llama.cpp
Reduce the context size
A smaller context window reduces KV-cache memory use:Change the quantization
Quantization affects model size, memory requirements, speed, and output quality. The source deployment guide uses:Load layers on the GPU
For a CUDA build:Enable flash attention
The example uses:Troubleshooting
llama.cpp is not ready
Check the health endpoint:- Docker
- Bare metal
Metrics are missing
Confirm that llama.cpp was started with:--metrics, the endpoint returns HTTP 404 and Hivenet Router cannot collect engine-specific metrics.
A metrics scrape failure does not stop the agent from forwarding requests.
The model name does not match
Check the name returned by llama.cpp:-a to set a stable alias:
Responses are slow
Possible adjustments include:- reduce
--capacityon the Hivenet Router agent - reduce llama.cpp’s context size
- use a smaller model or quantization
- increase GPU offloading
- reduce parallel request pressure
The agent does not register
Check the agent logs:- Docker
- systemd
- the router and agent use the same JWT secret
- the router’s libp2p interface is reachable
- the router advertises a libp2p address the agent can reach
- llama.cpp is healthy and exposes a model
The peer ID changes after restart
Make sure--identity-path points to persistent storage.
For Docker:
Requests time out
The agent’s backend HTTP timeout defaults to two minutes. Increase it for long-running requests:GPU metrics are missing
Check the host:Next steps
Infinity agent
Connect embedding and reranking models through Infinity.
Routing concepts
Learn how Hivenet Router filters and ranks matching agents.
Engine metrics
Understand the metrics collected from llama.cpp and other engines.

