Skip to main content
Hivenet Router’s client-facing API uses structured errors so applications can distinguish authentication, quota, routing, capacity, timeout, and backend failures. A typical response is:
Use:
for programmatic decisions. Use the HTTP status for broad error handling and message for diagnostics. Do not make application logic depend on the exact message text.

Response fields

Error source

Possible values are: The router value can describe an error generated by either the router process or Hivenet Router agent code. The backend value is also intentionally coarse. It does not identify which engine, provider, or machine produced the error.
An error message can contain text returned by the inference backend.Treat it as operational data. Do not display it directly to an end user without considering whether it exposes model, infrastructure, validation, or internal service details.

Response-format scope

The structured envelope is used by known client-facing /v1/* routes, including:
  • authentication failures
  • model discovery errors
  • inference validation errors
  • model-access denials
  • quota failures
  • routing and capacity failures
  • classified backend errors
Not every HTTP error produced by the complete server currently uses this envelope.

Administration endpoints

Many /admin/* validation responses use the simpler form:
Some administration errors also include additional fields:
See Admin endpoints for their endpoint-specific responses.

Unknown routes

A request to a route that Hivenet Router has not registered may receive an ordinary HTTP 404 rather than a structured Hivenet Router error. For example:
is not supported and does not enter the inference handler. Clients should therefore handle:
  • structured Hivenet Router errors
  • ordinary HTTP errors
  • connection failures
  • truncated streams

Error-code summary

The status shown is the normal mapping. Some internal failures explicitly return HTTP 500 with backend_error, while forwarded backend or provider failures normally map it to HTTP 502.

Request and authorization errors

request_invalid

Common triggers include:
  • malformed JSON
  • empty request body
  • missing model
  • model ID longer than 256 characters
  • an inference engine used with an unsupported capability
  • request parsing failure inside a Hivenet Router agent
Example:
Do not retry the same payload. Correct the request before sending it again.

context_length_exceeded

The inference backend determined that the request exceeded its effective context window. The total may include:
  • system or developer instructions
  • conversation history
  • tool definitions
  • tool results
  • multimodal content
  • requested maximum output
Example:
Reduce:
  • prompt size
  • retained conversation history
  • tool definitions
  • retrieved documents
  • max_tokens
  • max_completion_tokens
Do not retry the unchanged request against another agent serving the same model.

invalid_parameter

The backend rejected a field or value such as:
  • temperature
  • top_p
  • max_tokens
  • max_completion_tokens
  • reasoning_effort
  • roles or content blocks
  • tools or tool choice
  • structured-output options
  • model-specific parameters
Example:
Do not retry the same request. Inspect the backend message and compare the request with the exact model and engine configuration.

unauthorized

This covers both missing and invalid credentials. Hivenet Router deliberately returns the same response for both cases:
The response includes:
Possible causes include:
  • missing Authorization header
  • incorrect bearer key
  • client sending x-api-key instead
  • expired static or dynamic key
  • disabled dynamic key
  • removed key
  • using a key hash instead of the raw key
  • using an administrator key on a client route
  • using a client key on an administrator route
Do not retry until the credential or header is corrected.

model_forbidden

The key uses an explicit model allowlist and the requested model is not included.
Do not retry the same key and model combination. Use an allowed model or update the key’s access configuration.
A model missing from quota.per_model does not produce model_forbidden.That strict-enumeration case produces rate_limit_exceeded.

model_not_found

For inference, this normally means no agent currently registers the exact model ID.
The model-detail endpoint also returns this code when the model exists but is not visible to the caller:
This prevents one tenant from discovering another tenant’s model catalog. Check:
Retry only after:
  • correcting the model ID
  • registering an agent
  • restoring the agent
  • changing the key’s access

Request-size rejection

HTTP 413

Hivenet Router limits request bodies under /v1/* to:
by default, which is 10 MiB. A request above HIVENET_ROUTER_MAX_REQUEST_BYTES is rejected before it reaches the normal inference handler. That means the response body is not guaranteed to use Hivenet Router’s structured error envelope or a stable error.code. Handle this case using the HTTP status:
Reduce the request body, split large embedding or reranking batches, or change the configured byte limit. Set:
to disable the built-in limit, while accounting for any smaller reverse-proxy or ingress limit. Do not retry the unchanged request.

Quota errors

rate_limit_exceeded

This code covers request-rate admission, serverless per-key admission, and a missing strict per-model quota declaration.

RPM bucket exhausted

The response includes:
The RPM limiter refills continuously rather than resetting at the beginning of each wall-clock minute. Retry with bounded exponential backoff and jitter. Hivenet Router does not currently return a:
header, so the client must choose its own retry timing.

Serverless per-key limits

For a mode: serverless policy, this code also reports:
  • per-key occupancy share exceeded, please retry
  • input token rate exceeded, please retry
  • output token rate exceeded, please retry
These responses include Retry-After: 1. Occupancy and input-token limits reject the current request. Output tokens are charged after a response finishes, so an exhausted output bucket rejects a subsequent request.

Missing per-model quota declaration

A key using quota.per_model must enumerate every permitted model. An undeclared model returns:
This is a configuration error, not temporary RPM exhaustion. Do not retry until the key has a complete entry such as:

token_limit_exceeded

Hivenet Router can reject a token budget at two stages.

Before routing

The router checks whether this worst case fits:
A request may therefore be rejected even when it would probably generate a shorter answer. When output was reserved in the request, the message is:
The response can include a nonzero remaining value:
The request may succeed before the UTC reset when you reduce:
  • prompt size
  • max_tokens
  • max_completion_tokens

After non-streaming inference

The backend may complete the request before Hivenet Router knows the actual output-token count. When the completion no longer fits:
  • the response body is discarded
  • Hivenet Router returns 429
  • the prompt-token deduction remains
  • actual usage and the selected agent are preserved in the audit record
The response includes:
A token_limit_exceeded response does not always mean that the backend performed no work.For a post-response rejection, inference has already completed.

Streaming responses

Once a stream has started, Hivenet Router cannot replace the HTTP 200 response with a later JSON 429. Streaming output is accounted for after delivery. When it exceeds the remaining budget, Hivenet Router records the quota event in metrics, but the client retains the already delivered response.

Admission errors

input_too_long

This response is produced before routing when a policy’s max_input_tokens or images_max cap is exceeded:
Reduce the prompt or image count. Retrying an unchanged request will not help.

concurrency_limit_exceeded

This response is used when either:
  • the request would exceed the model’s token-weighted occupancy budget or max_inflight limit and capacity did not become available within HIVENET_ROUTER_ADMIT_PARK_TIMEOUT; or
  • aggregate healthy-pool engine pressure breached a configured shed_if threshold before queueing.
Retry with a short randomized delay. See Admission control for footprint and budget calculation.

Routing and capacity errors

no_agents_available

This is broader than “all agents are offline.” It means the full local policy chain ended without an eligible agent and no more specific model or capacity reason was available. Possible causes include:
  • agents offline or unhealthy
  • unhealthy inference backends
  • capability mismatch
  • static match filters
  • dynamic exclude_if gates
  • agents excluded after earlier failed attempts
  • a model-specific policy that matches no agents
  • all fallback steps exhausted
Messages can include:
or a more general policy-exhaustion explanation. Check:
Then inspect:
Retry with backoff when the failure is caused by a temporary fleet or health condition. A policy or capability mismatch requires configuration changes instead.

no_capacity

Healthy, filter-compatible agents exist, but every eligible agent has reached its declared concurrency capacity.
Before returning the error, Hivenet Router may:
  • wait in the per-model capacity queue
  • retry selection after a slot becomes available
  • advance through fallback steps
Retry after a short randomized delay. A sustained rate indicates that you should investigate:
  • agent --capacity
  • fleet size
  • request duration
  • engine queues
  • context and output lengths
  • per-model wait-queue depth

agent_disconnected

The selected agent could not be reached over the libp2p request path. Possible causes include:
  • stale peer connection
  • unreachable announced address
  • firewall or NAT change
  • agent restart
  • lost network path
  • process termination
Hivenet Router normally handles this internally first. It grants one connection reset and redial attempt per agent without consuming the policy step’s normal try budget. Further failures can cause another agent or fallback step to be selected. The client may therefore receive a later error such as:
  • no_agents_available
  • no_capacity
  • request_timeout
rather than the original agent_disconnected. When the code does reach the client, retry with backoff and inspect the agent connection path.

queue_full

The router’s global pending-request channel stayed full for five seconds.
This is controlled by:
It is distinct from the per-model capacity wait queue. When the per-model queue is full, the routing session advances through fallback steps. That condition does not directly return queue_full; the final response is normally no_capacity or no_agents_available. Retry with exponential backoff and investigate:
  • request arrival rate
  • --queue-size
  • --max-concurrent
  • agent capacity
  • backend latency
  • router CPU and memory

request_timeout

The router’s end-to-end deadline expired. The deadline can include:
  • waiting for processor concurrency
  • waiting in the per-model capacity queue
  • policy selection
  • retries
  • agent redial
  • agent forwarding
  • inference
  • provider fallback
Messages vary according to where the deadline expired:
A timeout is an ambiguous result.The backend may have received or even completed the request before the client received the timeout. Hivenet Router does not deduplicate retries by X-Request-ID.
Retry only when the application operation is safe to repeat. For systematic timeouts, inspect the request path before increasing:

Backend errors

backend_unavailable

For native Chat Completions, this can represent:
  • backend connection failure
  • model still loading
  • backend HTTP 429
  • backend HTTP 503
  • temporary engine overload
Example:
Hivenet Router normally treats this as retryable inside the routing session. It can try:
  • another agent
  • another local fallback step
  • an external provider fallback
The final client-visible error may therefore be no_agents_available rather than backend_unavailable. Retry with backoff when the backend condition is temporary.

backend_error

This is the catch-all for failures that Hivenet Router cannot classify more specifically. Possible causes include:
  • inference backend HTTP 500 or 502
  • unexpected backend response
  • invalid response JSON
  • provider fallback failure
  • unstructured error from a transparent proxy endpoint
  • storage or authentication-provider failure
  • another internal processing error
Example:
A local agent backend error is normally retried inside the policy chain. An external provider fallback failure returns backend_error directly because no routing step remains after that fallback. Retry once only when:
  • the request is safe to repeat
  • the failure appears transient
  • retrying will not worsen an overloaded backend
Repeated errors with the same input require investigation.

How native Chat Completions errors are classified

The Hivenet Router agent classifies non-success responses from the native:
handler before returning them to the router.

JSON error types

The classifier recognizes both:
and:
Known type mappings are: A recognized type takes precedence over the HTTP-status fallback.

HTTP and text fallback

When the error type is not recognized: For this native path, Hivenet Router extracts a message from the backend JSON where possible. Otherwise, it uses the raw body, truncated to 512 bytes.
A backend HTTP 429 is classified as backend_unavailable, not as Hivenet Router’s rate_limit_exceeded.rate_limit_exceeded describes Hivenet Router client-key quota admission.

Errors from transparent proxy endpoints

These paths use the agent’s generic transparent proxy:
The agent initially forwards the backend’s status and body without applying the native Chat Completions classifier. When the router receives a non-success response:
  1. It checks whether the body already contains a Hivenet Router structured error.
  2. If it does, that code and source are preserved.
  3. Otherwise, the router wraps the body as backend_error.
For example, an ordinary Anthropic-format backend error:
does not match Hivenet Router’s own envelope:
The final client response can therefore become:
rather than preserving the backend’s original HTTP 400.
Backend classification is currently more precise for native Chat Completions than for Messages, token counting, embeddings, and reranking.Inspect the backend log when one of the transparent endpoints returns a broad backend_error.

Internal routing retries

A backend or agent error is not necessarily returned to the client immediately. Hivenet Router distinguishes several categories.

Request-level errors

These stop the routing session immediately:
Trying the same request on another agent would normally produce the same outcome.

Connection failures

A stale or disconnected agent connection receives one free redial attempt per request. That redial does not consume the policy step’s max_tries budget.

Retryable forwarding failures

Other agent and backend errors can:
  1. mark the selected agent as failed in the current policy step
  2. select another eligible agent
  3. continue until max_tries is reached
  4. advance through the fallback chain
  5. use provider fallback where configured
Because of this, the client sees the final routing outcome rather than every internal attempt. For example:
Use audit logs, metrics, traces, and backend logs when the final error does not reveal the first failure.

Streaming error behavior

A structured JSON error can be returned only before response headers and body have started. After an SSE stream begins:
  • the HTTP status is already 200
  • some output may already have reached the client
  • Hivenet Router cannot replace the stream with a JSON error envelope
A failure during streaming can therefore appear as:
  • a stream ending early
  • an incomplete SSE event
  • a connection reset
  • a client-side parsing error
The client should treat an incomplete stream as a failed or partial operation, even when the initial HTTP status was 200. Use the request ID to inspect the associated audit record, router logs, agent logs, and trace.

Error response headers

Hivenet Router can add the following headers. Unlimited quota values are omitted rather than represented as negative numbers. Hivenet Router does not provide a general:
header for every retryable error. It is set on admission-capacity rejection. Backend error headers are not guaranteed to be preserved when Hivenet Router converts a backend response into a structured error.

Correlate an error

Every router response includes:
Log this value in the calling application. Search it in Loki:
The audit record can show:
  • tenant
  • dynamic key ID
  • model
  • status
  • error code
  • selected agent
  • latency
  • token counts
  • trace ID
Use the trace ID in Tempo for the complete distributed request path.

Diagnose by status

HTTP 400

Check:
  • request JSON
  • required model and message fields
  • context length
  • model-specific parameter support
  • tools and structured-output schemas
  • backend logs

HTTP 401

Check:
  • raw bearer key
  • credential expiration
  • dynamic key state
  • correct client or administrator key type
  • reverse-proxy header forwarding

HTTP 403

Check the explicit model allowlist.

HTTP 404

Check:
  • endpoint path
  • base URL construction
  • exact model ID
  • client model visibility
  • registered agents
A plain 404 may mean an unsupported route. A structured model_not_found refers to model discovery or routing.

HTTP 413

Reduce the request body or split a large batch. Check both HIVENET_ROUTER_MAX_REQUEST_BYTES and any reverse-proxy or ingress body limit.

HTTP 429

Inspect:
Distinguish:
  • RPM exhaustion
  • undeclared per-model quota
  • insufficient worst-case token budget
  • exhausted daily token budget

HTTP 503

Inspect the specific code.

HTTP 504

Check:
  • global queueing
  • per-model queueing
  • policy retries
  • connection resets
  • backend queue depth
  • model loading
  • prompt and output size
  • router request timeout

Client retry guidance

Before retrying, determine both:
  • whether the error is temporary
  • whether repeating the application operation is safe
Hivenet Router does not use X-Request-ID as an idempotency key.Sending the same ID again creates another inference operation.
Official SDKs and frameworks may add their own automatic retries. Account for those retries when setting:
  • request quotas
  • application deadlines
  • maximum attempts
  • concurrency
  • audit expectations

Production handling

A production client should:
  1. Parse structured errors when the body matches the Hivenet Router envelope.
  2. Preserve the HTTP status and X-Request-ID.
  3. Handle ordinary HTTP errors when no structured envelope exists.
  4. Distinguish temporary capacity failures from request defects.
  5. Apply bounded retries with exponential backoff and jitter.
  6. Avoid retrying unsafe or ambiguous operations automatically.
  7. Log the code, status, source, request ID, and model.
  8. Avoid logging credentials or complete sensitive prompts.
  9. Alert on sustained error rates rather than individual transient failures.
  10. Use audit records and traces for detailed investigation.

Next steps

Performance characteristics

Understand queueing, concurrency, latency, throughput, and benchmarking behavior.

Use from code

Handle Hivenet Router errors from Python, JavaScript, SDKs, and direct HTTP clients.

Routing concepts

See how retries, fallback steps, capacity, and policy exhaustion affect the final response.

API keys

Configure the request and token quotas behind 429 responses.

Admin endpoints

Diagnose fleet health, capacity, routing state, and dynamic key errors.

Audit logging

Correlate error codes with tenants, models, agents, request IDs, and traces.