Supported providers
Hivenet Router currently supports:
Provider names are lowercase and case-sensitive.
Hivenet Router supports one
fallback_provider per policy. It does not provide an ordered chain of several external providers.
Configure provider fallback
fallback_provider is a top-level policy field.
Do not place it inside routing_policy or fallback_chain.
<provider-model> with a model currently available to your provider account.
The block requires both fields:
The router rejects a policy when:
engineis missingmodelis missing- the provider is not supported
- the required provider API key is not configured
Configure credentials
Provider credentials are router configuration. They do not belong in the policy YAML.OpenAI
Anthropic
Docker Compose
Keep the host-side secret in.env:
.env file:
systemd
Create a protected environment file:When provider fallback runs
Hivenet Router attempts the provider only after every local policy step has been exhausted. Local routing may be exhausted because:- no agents are registered for the requested model
- all matching agents are unhealthy
- no agent serves the required capability
- static filters remove every agent
- live policy gates remove every candidate
- matching agents remain at capacity
- local forward attempts exhaust their retry budgets
llm capability.
It is not used for:
- embeddings
- reranking
- malformed request data
- invalid parameters
- a context-length failure
- a token-quota rejection
Use it for chat generation
Provider fallback is designed for OpenAI-style chat-generation requests:/v1/messages may lose fields that are outside the subset understood by Hivenet Router’s fallback adapters.
For predictable behavior, use /v1/chat/completions with a non-streaming text request.
Model substitution
The provider model replaces the model requested by the client. For example, the client may request:- the response may come from a different model family
- response quality and behavior may differ
- tokenization and context limits may differ
- provider billing applies to the substituted model
- the provider model does not need to be registered by a Hivenet Router agent
Client access and quotas
Hivenet Router authorizes the original requested model before routing. For example, the client API key must be allowed to request:- The request-per-minute deduction, input-tokens-per-minute charge, and daily input reservation taken before routing remain in place.
- The global and per-key occupancy reservations are released as soon as routing hands the request to the provider.
- Provider output does not charge the local output-tokens-per-minute bucket, and provider usage does not train the local model’s learned estimator.
- The provider path does not perform the normal post-response daily output-token deduction. Only the input reservation taken before routing affects the daily bucket.
- Provider-reported input and output usage is still recorded in tenant Prometheus counters and the audit log, attributed to the originally requested model.
OpenAI fallback
Configure:Request handling
The OpenAI adapter re-encodes the fields represented by Hivenet Router’s internal chat request. These include:- messages
- temperature
top_pmax_tokensmax_completion_tokens- modalities and audio configuration
- service tier
- tools
- tool choice
- structured-output configuration
- stop sequences
- log probabilities
- provider-specific extensions
Response handling
Hivenet Router decodes the provider response into its OpenAI-compatible response type. The response must:- return HTTP
200 - contain at least one choice
- contain valid JSON in the expected chat-completion shape
Anthropic fallback
Configure:Request translation
Hivenet Router converts its OpenAI-style internal chat request into an Anthropic Messages request. It:- replaces the model with the configured Anthropic model
- joins system-role messages into one top-level
systemstring - forwards user and assistant messages
- extracts text from message content
- forwards
temperature - forwards
max_tokens - uses
4096whenmax_tokensis absent
- image content
- audio content
- tools and tool definitions
- tool results
- structured output
top_pmax_completion_tokens- other provider-specific fields
Response translation
Hivenet Router converts the Anthropic response into an OpenAI-compatible chat response. It:- uses the first text content block as the assistant message
- maps input tokens to
prompt_tokens - maps output tokens to
completion_tokens - calculates
total_tokens - maps
max_tokensto the finish reasonlength - maps
tool_usetotool_calls - maps other stop reasons to
stop
Streaming limitations
Provider fallback is not implemented as a streaming adapter. Use:stream.
For OpenAI, a request with:
Timeout behavior
Provider clients use a default HTTP timeout of:- the remaining Hivenet Router request deadline
- the provider client timeout
- queue depth
- local retry budgets
- fallback-chain length
- router request timeout
Complete OpenAI example
Complete Anthropic example
Test provider fallback
Use a temporary policy that cannot match any local agent. For example:model should be the configured provider model rather than the original local model.
Restore the production policy after the test.
Monitor provider fallback
Successful provider fallbacks:hivenet_router_policy_provider_fallback_total counts successful provider responses, not every attempted provider call.Use the outbound HTTP histogram and router logs to observe failed attempts.Failure behavior
Hivenet Router makes one outbound provider call. It does not:- retry the same provider automatically
- try another external provider
- return to local routing after the provider fails
502:
- invalid credentials
- an unavailable provider model
- provider rate limits
- provider quota or billing limits
- request incompatibility
- an upstream server error
- a network error
- request timeout
- a response with no usable completion
Operational guidance
Treat fallback as a changed execution boundary
A request may leave infrastructure you control and enter an external provider environment. Make that behavior explicit to:- application owners
- security teams
- compliance teams
- customers whose data may be processed
- incident responders
Monitor fallback volume
A sustained rise in provider fallback may indicate:- insufficient local capacity
- unhealthy agents
- overly strict policy gates
- network instability
- incorrect agent metadata
- local model deployment problems
Control provider spending
Provider requests may incur separate input and output charges. Use:- provider-side spending limits
- budget alerts
- restricted project credentials
- Hivenet Router fallback metrics
- tenant and model quotas
Rotate credentials
Use a secrets manager where available. After rotating a provider key:- update the router environment
- restart the router
- confirm that the policy loads
- run a controlled fallback test
- revoke the old credential
Troubleshooting
The router does not start
Check the error message. If the policy uses OpenAI, confirm:A policy reload is rejected
A policy added throughSIGHUP or the admin API is validated against the provider credentials loaded at router startup.
Adding the environment variable to your shell after the router is running is not enough. Restart the router so it can create the provider adapter.
Fallback is never attempted
Check that:- every local routing step was exhausted
- the request uses the
llmcapability - the request did not fail with a non-retryable client error
fallback_provideris at the policy’s top level- the request deadline has not already expired
The provider model is rejected
The external model name is independent of the model registered in Hivenet Router. Confirm that:- the model exists at the provider
- the provider account may access it
- the model name is spelled exactly
- the credential belongs to the expected provider account or project
OpenAI fallback fails only for streaming requests
Set:Anthropic fallback loses system or content data
System-role messages are joined into the top-level Anthropicsystem field.
Anthropic-native top-level fields and non-text content may not survive the conversion into Hivenet Router’s internal OpenAI-style request.
Use a simple text Chat Completions request when provider fallback must behave predictably.
Anthropic returns a tool-use response and fallback fails
The current response translator requires at least one text content block. Tool-only responses are treated as provider errors. Do not depend on Anthropic tools through provider fallback in the current implementation.The provider call times out
Check how much of the original request deadline was consumed by:- local retries
- capacity waiting
- local fallback steps
Next steps
Policy gates
Apply practical health, latency, cache, and hardware thresholds.
Prometheus metrics
Monitor provider usage, latency, failures, and policy exhaustion.
Audit logging
Record request outcomes, tenants, models, and routing behavior.

