Skip to main content
Hivenet Router is configured through command-line flags, environment variables, and two optional YAML configuration surfaces:
  • auth.yaml for client and administrator authentication
  • policy YAML for routing, fallback, and dynamic gates
This page covers process-level router and agent configuration. See auth.yaml reference and Policy YAML reference for the file schemas.

View the installed options

Use the binary’s built-in help to confirm the options available in the version you deployed:
For API-key generation:
The environment-variable prefix is exactly:
Environment-variable names are case-sensitive on Linux. Use the capitalization shown in this reference.

Configuration precedence

The router loads configuration in this order:
For example:
The router listens on:

Agent precedence

Most agent settings are available only as command-line flags. The current agent reads these Hivenet Router environment variables directly:
Other agent environment variables that resemble flag names are not loaded automatically. For example, this does not currently configure the agent:
Use:
instead.
Do not assume that every flag has an environment-variable equivalent.Only the mappings explicitly shown on this page are implemented.

Value formats

Durations

Duration flags and environment variables use Go duration syntax:
Examples:
--disk-db-ttl is different. It accepts an integer number of days rather than a duration string.

HTTP and gRPC listen addresses

Router HTTP, gRPC, and metrics values are complete TCP listen addresses. Listen on every interface:
Listen only on loopback:

libp2p ports

The router’s --p2p-port accepts a port without a colon:
libp2p announce and bootstrap addresses use multiaddress syntax:

Paths

Relative paths are resolved from the process’s working directory. For a system service or container, prefer explicit paths such as:

Tags

Agent tags are comma-separated:
Do not add spaces after commas. The current parser splits on commas without trimming each value. This:
creates the tags:
The second value includes a leading space and will not match:

Router network settings

HTTP API

The HTTP server exposes:
Use a reverse proxy or another ingress layer for TLS. The HTTP server does not enable HTTPS itself.

Metrics

The metrics server is separate from the main HTTP API:
It has no built-in authentication. Keep it on a private interface or protect it through network controls.

Remote agents

The router’s libp2p host binds to loopback by default:
For agents on other machines:
When the bind address is not the address agents should dial, also set:
The announce value must be a valid multiaddress. An invalid value stops router startup.

Agents behind shared NAT

Agents behind one NAT or egress gateway appear to libp2p as connections from one source IP. Set:
comfortably above the number of agents sharing that address. A practical starting point is:
The additional room covers reconnect overlap during restarts and fleet rollouts.

Router routing and backpressure settings

Built-in policy

When no policy file or directory is configured, Hivenet Router uses:
with:
  • no static filters
  • no dynamic exclusions
  • no local fallback steps
  • no provider fallback

Policy-file precedence

When both are configured:
and the model-policy directory contains:
the directory’s _default.yaml becomes the global policy. Hivenet Router logs a warning that it replaced the standalone policy file. Named policy files in the directory can claim specific models.

Global request queue

--queue-size controls the buffered request channel before processor work begins. When the channel remains full for the handler’s enqueue window, Hivenet Router returns:
Use a positive value.

Per-model wait queue

--queue-depth controls how many requests can wait for capacity for each model.
disables capacity waiting. A request encountering full eligible agents then advances directly through its fallback path.

Concurrent forwards

--max-concurrent limits requests actively being forwarded to agents. It is separate from:
  • the global request-channel size
  • the per-model wait queue
  • each agent’s declared capacity

Request deadline

--request-timeout covers:
  • time waiting for processor concurrency
  • policy evaluation
  • time waiting in a per-model capacity queue
  • retries and fallback steps
  • agent forwarding
  • response or stream handling
A longer client or agent timeout cannot extend a shorter router deadline.

Router health and session settings

Keep these relationships:
The defaults are:
The router does not currently reject every inconsistent combination of these timing values.Changing them makes you responsible for preserving a coherent ordering.

Session lifetime

The session TTL must be longer than:
The router refuses to start when it is five minutes or less because agents begin renewal five minutes before expiration. Agents normally:
  • authenticate once
  • receive a one-hour session
  • renew five minutes before expiry
  • retry failed renewal after 30 seconds

Router storage settings

The persistent database can contain:
  • per-agent request and token history
  • SRTT and RTTVAR
  • disconnection and failure history
  • daily token state when the Badger quota backend is active

Database reset

deletes the configured database directory before the router opens it.
Do not use --reset-disk-db as a normal recovery step.It removes persisted agent history and Badger-backed daily quota state from that directory.

Universal flush interval

The same interval is currently used for:
  • universal per-agent history flushes
  • Badger-backed quota flushes
Request-per-minute quota buckets remain in memory even when the Badger quota backend is enabled.

Router security and authentication settings

Agent JWT secret

The router requires a shared secret containing at least:
Recommended file-based configuration:
Environment-based configuration:
When both are provided, --jwt-secret-file wins. The file’s leading and trailing whitespace is removed, so a final newline is safe. The value must match every agent exactly. Changing it changes:
  • JWT validation
  • the router’s derived gRPC TLS identity
  • the public key pinned by agents
Rotate it as a coordinated router-and-agent change.

Authentication file

controls:
  • client API authentication
  • administrator authentication mode
  • static client keys
  • model access
  • quotas
  • static expiration
See auth.yaml reference.

Router environment-only settings

These settings do not have equivalent router command-line flags.

HIVENET_ROUTER_AUTH_MODE

Accepted API modes are:
This variable is read only when no auth configuration file is set. When auth.yaml is present, its:
value takes precedence.
Setting:
without an auth.yaml file does not provide any static keys.Startup fails because the key list is empty. Use an auth file for static API-key mode.
Dynamic mode automatically requires administrator authentication and:

HIVENET_ROUTER_ADMIN_API_KEYS

Provide one or more raw keys separated by commas:
Whitespace around values is removed. Administrator keys are separate from client API keys.

HIVENET_ROUTER_ALLOW_INSECURE_ADMIN

The router refuses to start with unauthenticated administrator endpoints unless you explicitly set:
Use this only for isolated local development or testing. In shared, remote, or production environments, configure administrator API-key authentication instead.

HIVENET_ROUTER_MAX_REQUEST_BYTES

The default maximum request body size for /v1/* endpoints is:
which is 10 MiB. Requests above the configured limit are rejected with HTTP 413 before routing. Set another byte value to change the limit, or:
to disable it. A reverse proxy may enforce a smaller limit before the request reaches Hivenet Router.

Admission environment variables

HIVENET_ROUTER_ADMIT_FRACTION scales a policy’s admit_budget_tokens before the router admits token-weighted occupancy. It defaults to 0.90; invalid values or values outside (0, 1] leave the default unchanged. HIVENET_ROUTER_ADMIT_PARK_TIMEOUT bounds how long an over-budget request waits for occupancy to free. It uses Go duration syntax, defaults to 250ms, and accepts 0 for immediate rejection. Negative or invalid values leave the default unchanged. HIVENET_ROUTER_RPM_BURST_SECONDS changes the burst capacity of both flat and per-model RPM buckets. With a value from 1 through 59, burst capacity is floor(effective RPM × seconds / 60), with a minimum of 1. The default 0 preserves the legacy full-minute burst. Invalid values and values outside [0, 60) leave that default unchanged. See Admission control for policy fields, footprint calculation, and error responses.

HIVENET_ROUTER_QUOTA_BACKEND

Supported values are:
memory:
  • keeps RPM and daily token state in process memory
  • loses both after a router restart
badger:
  • keeps RPM buckets in memory
  • periodically persists daily token use
  • restores daily token state after restart
Any other value stops router startup.

Provider credentials

Provider fallback credentials are read when the router starts:
If an active policy refers to a provider whose key is absent, startup fails. Changing a provider credential requires a router restart.

Audit path

The router creates the parent directory when possible. When it cannot open the file, it writes audit JSON to standard output instead. Changing the path requires a router restart.

Router flag reference

The complete current router flag set is:

Agent backend settings

Supported engines

Accepted values are:

Model discovery

When --model is empty, supported engine adapters try to discover a model from the backend. Use an explicit model value when:
  • the backend exposes several models
  • the client-facing alias must remain stable
  • backend discovery is unreliable
  • the custom engine is selected
A custom engine requires both:

Capability

Accepted values are:
The router combines the model name and capability when selecting an agent. Ollama currently cannot be registered with:
because its integration does not expose the required reranking endpoint.

Capacity

Capacity must be positive. It is an operator-defined concurrency limit, not a value calculated from GPU memory or model size. The router rejects agent authentication when the reported capacity is zero or negative.

Backend and router timeouts

The agent’s default backend HTTP timeout is:
The router’s default request timeout is:
The shorter router deadline usually ends the client operation first.

Stream write timeout

--stream-write-timeout is a rolling per-chunk deadline. When the router or another receiver stops reading a stream, the agent eventually releases the blocked write rather than holding the libp2p stream indefinitely. Set:
to disable it.

Agent router and libp2p settings

Router discovery

The agent currently obtains the router’s actual libp2p addresses from the gRPC authentication response. The accepted:
flag is not read by the current connection sequence. Configure:
and make sure the router advertises a reachable libp2p address through:
when necessary.

Persistent identity

Use a persistent identity path:
Preserving this file preserves the agent’s peer ID. A stable peer ID lets the router associate the agent with earlier:
  • request counters
  • token counts
  • SRTT and RTTVAR
  • disconnection history

Agent connection direction

Agents initiate their libp2p connection to the router after successful gRPC authentication. The router forwards inference traffic over that established connection rather than opening a new inbound connection to the agent. The default:
lets the operating system choose a local port. A fixed port is rarely needed and does not create a requirement to expose that port to the router.
Do not add inbound agent firewall rules, public agent port mappings, or NAT forwarding solely for Hivenet Router request forwarding. Agent hosts need outbound access to the router’s gRPC and libp2p ports.

Agent metadata settings

Region default

The current code default is literally:
This is an operator-defined label rather than a validated region code. Override it with the convention used in your deployment:
or another stable value.
Region, organization, machine, tags, and GPU model become routing and observability labels.Keep them stable and bounded. Do not put user IDs, request IDs, timestamps, or other unbounded values in these fields.

Version

Release builds can inject a version at build time. A local build without an injected value reports:
The --version flag changes registration metadata only. It does not select or install another agent software version.

GPU model

--gpu-model is not detected automatically through NVML. Set a consistent operator-defined value when routing policies use:

Deployment ID

The deployment ID is included in agent registration and used in tenant request metrics. It may be empty in local or bare-metal deployments that do not have a separate deployment identity.

Replica ID

--replica-id supplies a stable identifier for one agent replica. When --deployment-id is also set, the two values form a join key for external schedulers and registration-stream consumers.

hide_llm metadata

An agent with:
sets the aggregated model object’s:
metadata flag. The current catalog implementation still includes that model in /v1/models. Do not use this flag as an access-control or reliable discovery-hiding mechanism. Use API-key model restrictions to control which models a caller can discover and invoke.

Agent telemetry settings

Sampling and push intervals

Sampling and pushing are independent. For example:
causes the same cached hardware snapshot to be sent several times before the next sample. Reducing only the routing-signal interval does not increase hardware collection frequency.

GPU-device file

The file accepts NVIDIA GPU UUIDs separated by commas or line breaks. When it is empty or contains:
the agent reports no GPU metrics. When no file is configured, the agent reports every NVIDIA GPU visible to the process. After the file has loaded successfully, restart the agent to apply later changes. See Hardware metrics.

Agent flag reference

The complete current agent flag set is:

Logging configuration

Both processes use go-log.

Log level

Set one global level:
Or configure application subsystems individually:
The application-defined subsystems are:
Dependencies such as libp2p may emit additional subsystem names.

JSON logs

For structured application logs:
The agent adds its peer ID as a process-wide structured label. Audit records remain in their separate JSONL output. Logging environment variables are read at process startup.

Distributed tracing

Set an OTLP gRPC endpoint on the router, agents, or both:
When the variable is empty or absent, tracing is disabled. The current exporter uses an insecure OTLP gRPC connection. Put the collector on a trusted network or use an appropriate protected intermediary. The processes identify themselves as:
Changing the endpoint requires a process restart.

Environment parsing behavior

Router environment variables are loaded before CLI parsing. For typed router values such as integers and durations, an invalid environment value is generally ignored and the previous default remains active. For example:
does not produce a valid duration and is ignored. The router therefore continues with:
unless a CLI flag overrides it.
Invalid typed router environment values do not consistently stop startup.Read the router startup banner and verify the resolved configuration after every deployment change.
Invalid command-line values are more visible because Go’s flag parser normally exits with an error. Configuration values such as invalid auth modes, quota backends, policy files, and provider requirements fail during subsystem initialization.

Startup validation

Router validation

Router startup fails for conditions including:
  • missing JWT secret
  • JWT secret shorter than 32 bytes
  • session TTL of five minutes or less
  • max-tries-per-step below 1
  • negative queue depth
  • invalid libp2p announce address
  • invalid policy YAML
  • invalid per-model policy directory
  • unknown authentication mode
  • static API-key mode without keys
  • administrator API-key mode without administrator keys
  • unknown quota backend
  • provider fallback without the required provider key
  • storage initialization failure
Use positive values for:
even where the command entry point does not currently perform a dedicated validation check.

Agent validation

Agent startup or authentication fails for conditions including:
  • missing JWT secret
  • JWT secret shorter than 32 bytes
  • unknown engine
  • custom engine without a model
  • custom engine without a health URL
  • unknown capability
  • Ollama configured as a reranker
  • backend that never becomes ready
  • model discovery that never returns a model
  • non-positive capacity rejected by the router
  • JWT secret that does not match the router
  • unreachable router gRPC or libp2p interfaces

Reload or restart

Editing a systemd EnvironmentFile, Docker .env file, or Kubernetes Secret does not modify the environment of an already running process. Recreate or restart the process when the changed value comes from its environment.

Send SIGHUP

Bare metal:
systemd:
Docker Compose:
Inspect the router logs after reload. An invalid file leaves the previous valid configuration active, but the attempted change has not taken effect.

Router startup example

This example:
  • exposes gRPC and libp2p for remote agents
  • keeps the client API behind a local reverse proxy
  • keeps metrics on loopback
  • reads secrets and configuration from explicit paths
  • uses a policy directory
  • persists state outside the working directory

vLLM agent example

The example does not set --router-p2p. The current agent receives the router’s dialable libp2p address during gRPC authentication.

Custom-engine example

A custom engine must implement the client-facing endpoint used by the request. Hivenet Router does not translate its API schema.

Generate a static client key

Run:
The subcommand:
  • generates 32 random bytes
  • encodes a key beginning with sk-hivenet-
  • prints the raw key once
  • prints its SHA-256 hash
  • prints a masked preview
  • produces an auth.yaml entry
The tenant defaults to:
The value is limited to 200 characters. Store the raw key in a secret manager. Put only the generated hash in auth.yaml.

Next steps

auth.yaml reference

Configure static keys, administrator access, model restrictions, and quotas.

Policy YAML reference

Configure primary routing, fallback chains, provider fallback, and gates.

Detailed architecture

See where each configuration value affects the running system.

Error codes

Diagnose startup, authentication, routing, and backend failures.

Key rotation

Rotate client, administrator, agent, and provider credentials.

Prometheus metrics

Verify runtime behavior after configuration changes.