- agents joining the inference network
- clients calling
/v1/*endpoints - operators calling
/admin/*endpoints
/admin/* endpoints unless HIVENET_ROUTER_ALLOW_INSECURE_ADMIN=true is set explicitly.

Authentication boundaries
Agent authentication is separate from the two HTTP authentication surfaces. Setting the client API to
none does not disable router-agent authentication.
Agent authentication
Every agent must authenticate before it can register with the router. The router and every agent share one high-entropy secret. Hivenet Router uses that secret for two related purposes:- signing and validating agent JWTs
- deriving the gRPC TLS identity used during authentication
Agent authentication flow
An agent joins the network in two stages.1. Authenticate over gRPC
The agent:- creates a JWT signed with HMAC-SHA256
- includes its libp2p peer ID as the JWT subject
- connects to the router’s gRPC authentication endpoint
- verifies the router’s pinned TLS public key
- sends the JWT and its agent metadata
- verifies the JWT signature
- validates its issuer, issue time, expiry, and subject
- validates required agent metadata
- creates a random session token
- returns the session token, router libp2p addresses, and runtime configuration
2. Register over libp2p
After gRPC authentication, the agent connects to the router’s libp2p endpoint and presents the session token. The router links:- the authenticated agent identity
- the agent’s libp2p peer ID
- its registered model and metadata
- the short-lived session
Agent metadata validation
The router rejects authentication when required metadata is missing or invalid. Required fields include:- model
- positive capacity
- agent version
- engine
- region
- organization
- capability
- machine identifier
- tags
- GPU model
- display name and model description
Agent sessions
The session token is separate from the initial JWT.
Configure the router session lifetime:
Client API authentication
Client authentication protects the/v1/* endpoints, including:
- chat completions and messages
- embeddings
- reranking
- model discovery
No authentication
When noauth.yaml is configured and HIVENET_ROUTER_AUTH_MODE is unset, the client API uses:
Authorization header.
The authenticated tenant is recorded internally as:
Static API keys
Static mode loads hashed API keys fromauth.yaml.
- the raw client key, shown once
- its SHA-256 hash
- a masked preview
- a ready-to-paste
auth.yamlentry
- tenant identity
- human-readable metadata
- expiration
- model restrictions
- request-rate limits
- daily token limits
- per-model quotas
SIGHUP after changing auth.yaml:
A successful authentication reload rebuilds in-memory quota state. Request-rate buckets reset. Daily token usage also resets with the
memory quota backend, while the badger backend preserves and restores daily token state.Dynamic API keys
Dynamic mode uses an in-memory key registry managed through protected administration endpoints. Enable it when noauth.yaml is provided:
Client request format
Send the raw client key in the standard bearer header:Bearer prefix, but the standard bearer format is recommended for clients and proxies.
What successful authentication provides
After a client key is authenticated, Hivenet Router adds its resolved access information to the request context. This includes:- tenant or owner ID
- dynamic key ID, when applicable
- masked key preview
- allowed models
- quota configuration
- model authorization
- request-rate enforcement
- token-budget enforcement
- tenant metrics
- audit records
Model access control
A client key can be limited to specific models. For static keys:403:
quota.per_model is configured, its model names become the effective allowlist. A model missing from that map is hidden from discovery and rejected for inference with HTTP 429 rate_limit_exceeded, rather than 403 model_forbidden.
See Model restrictions for the complete behavior.
Administration authentication
Administration authentication protects/admin/*.
Configure it separately in auth.yaml:
auth.yaml.
Changing a systemd environment file, Docker .env file, Kubernetes Secret, or shell configuration does not change the environment of an already running router. Restart or recreate the router after changing HIVENET_ROUTER_ADMIN_API_KEYS.
Use an admin key:
admin.mode is none, the router refuses to start unless you also set:
Configuration precedence
When an auth configuration file is provided:
Invalid modes, empty required key lists, malformed hashes, duplicate hashes, invalid expiry dates, or invalid quotas prevent the router from starting or reloading the configuration.
Authentication failures
Missing, malformed, expired, and unknown client or admin credentials receive the same response.- the header was missing
- the key was unknown
- the key had expired
- the key was disabled
Transport security
Hivenet Router protects different network paths differently.
For production client traffic, place Hivenet Router behind a reverse proxy, ingress, or load balancer that provides HTTPS.
For example:
- gRPC and router libp2p ports to agent hosts
- administration endpoints to operators or management networks
- Prometheus endpoints to monitoring systems
Secret responsibilities
Do not reuse one value for several roles.
Compromise has different consequences:
- the agent secret allows unauthorized agents to join
- a client key allows requests within that key’s permissions and quotas
- an admin key allows operational access and possibly key-registry changes
- a provider key allows billable external-provider use
Recommended production baseline
- Generate a strong shared agent secret.
- Store it through a secrets manager on the router and agents.
- Enable static or dynamic authentication for
/v1/*. - Enable administration API-key authentication.
- Use distinct client, admin, agent, and provider credentials.
- Restrict each port at the network layer.
- terminate client-facing HTTPS before the router.
- Apply least-privilege model access and quotas.
- Enable audit logging and authentication metrics.
- Define and test a rotation process.
Troubleshooting
An agent reports a TLS key mismatch
The router and agent are using different JWT secrets. Compare their secret files without printing their contents:The router rejects the agent metadata
Check the agent logs for the field named in the rejection. Required values include:- model
- positive capacity
- version
- engine
- region
- organization
A client receives 401 unauthorized
Check that:
- the correct key is being sent
- the header uses the expected value
- the router loaded the intended auth configuration
- the static key has not expired
- a dynamic key is enabled and present after the latest router restart
- the request is reaching the intended router environment
A valid client key receives 403 model_forbidden
Authentication succeeded, but the key may not use the requested model.
Review:
modelsfor static keysallowed_modelsfor dynamic keysquota.per_model- exact model spelling and capitalization
Administration requests receive 401
Client and administration credentials are separate.
Confirm that:
Static changes do not take effect
SendSIGHUP:
auth.yaml.
Dynamic keys disappear
The dynamic registry is stored in memory. Repopulate it through the administration API after every router restart.Next steps
API keys
Generate, configure, manage, and revoke static and dynamic client keys.
auth.yaml reference
Review the complete static authentication and quota schema.
Key rotation
Rotate agent, client, administrator, and provider credentials safely.

