llm agent, and forwards the original request to the backend at the same path.
Prerequisites
Before configuring Claude Code, you need:- a reachable Hivenet Router router
- a Hivenet Router client API key
- at least one healthy agent registered with the
llmcapability - a backend that implements the Anthropic Messages API
- a model with reliable structured tool calling
- HTTPS when the router is reached over an untrusted network
Prepare a compatible backend
vLLM supports the Anthropic Messages API and can serve tool-capable open models to Claude Code. A typical command resembles:Use a stable served-model alias
Prefer a short, stable alias for the model Claude Code will request:- vLLM’s
--served-model-name - the Hivenet Router agent’s registered model
- the Claude Code model mapping
- the API key’s model restrictions or per-model quotas
Test the backend directly
Before adding Hivenet Router or Claude Code to the path, confirm that the backend accepts an Anthropic-format request:Test the Hivenet Router path
List the models visible to the Claude Code API key:- client authentication
- model access
- routing
- agent connectivity
- backend Messages support
- response forwarding
max_tokens is required by the Anthropic Messages request format.A hand-written request without it may be rejected by the backend even though the equivalent Chat Completions request succeeds.Install Claude Code
- macOS, Linux, or WSL
- Windows PowerShell
Configure Claude Code
Set the router URL, client credential, and model aliases before launching Claude Code:/v1 to the base URL.
Correct:
/v1 in the configured base URL can produce:
Use the bearer-token variable
Use:x-api-key.
Unsetting ANTHROPIC_API_KEY also prevents an unrelated Anthropic API key from taking part in credential selection:
You do not normally need to sign out of an existing claude.ai account.
ANTHROPIC_AUTH_TOKEN takes precedence while it is set. The saved login remains available and becomes active again after you remove the gateway variables.Run /logout only when you deliberately want to remove the saved login or Claude Code reports an unresolved authentication conflict.Map the model aliases
Claude Code uses built-in model aliases for different kinds of work.
You may map every alias to one model:
- appear in
/v1/modelsfor the client key - be registered by a healthy
llmagent - support the request features Claude Code sends
- be included in the key’s model restrictions or per-model quotas
haiku even when you intend to work mainly through sonnet or opus. Claude Code can use the Haiku alias for background functionality.
Verify the active configuration
Start Claude Code:- the Hivenet Router address as the Anthropic base URL
ANTHROPIC_AUTH_TOKENas the active credential source- the intended model or model alias
- Claude Code was started from another terminal
- an editor was launched before the variables were exported
- a settings file overrides the shell value
- a wrapper or background process uses another environment
Test the coding workflow
Start with a simple prompt:- proposes or invokes the appropriate file tool
- receives a structured tool response from the model
- creates the expected file
- continues the conversation after the tool result
Make the configuration persistent
Claude Code supports several settings scopes.
A user-wide configuration can look like:
/status to confirm which value is active.
Use a credential helper
For short-lived or externally managed keys, configure:Authorization header.
By default, Claude Code caches the helper result for five minutes and runs it again after an HTTP 401.
Change the cache period with:
ANTHROPIC_AUTH_TOKEN has higher credential precedence than apiKeyHelper.Remove the static token when the helper should become authoritative.Add a custom model to the picker
The alias mappings are the simplest way to expose Hivenet Router models. You can also add one explicit custom entry:Gateway model discovery
Claude Code can optionally query:ANTHROPIC_CUSTOM_MODEL_OPTION instead of renaming an open model to imply that it is a Claude model.
Do not combine gateway model discovery with:The nonessential-traffic setting disables discovery.
Restricted-egress environments
Claude Code can make non-inference requests outside the configured gateway path for update checks, telemetry, release information, and other auxiliary behavior. On a network that permits access only to Hivenet Router, set:- disables automatic updates
- disables gateway model discovery
- suppresses the fast-mode availability check
- leaves some WebFetch safety traffic subject to separate settings
Request and header behavior
Claude Code sends Anthropic-format requests, including evolving:anthropic-versionheadersanthropic-betaheaders- tool schemas
- system content
- context-management fields
- reasoning and output-configuration fields
Streaming
Claude Code expects server-sent events to arrive progressively. The complete path must preserve streaming:- whether the backend returns
text/event-stream - whether the agent is current
- whether the reverse proxy buffers responses
- whether proxy timeouts are long enough
- whether the client requested streaming
Compatibility with new Claude Code features
Claude Code may send fields that an older or non-Anthropic backend does not support. Common failures include backend errors naming:Use Hivenet Router and Anthropic side by side
A saved claude.ai login can remain on the machine. Create a launcher for Hivenet Router:Observe Claude Code traffic
Audit records identify the tenant, model, selected agent, status, and request duration. Search one tenant in Loki:Troubleshooting
Claude Code opens the login screen
The gateway credential did not reach the process. Check:/status after it opens.
/status shows no Anthropic base URL
Claude Code is not using the Hivenet Router endpoint.
Check for:
- a missing environment variable
- a settings-file override
- an editor or launcher with another environment
- a misspelled variable name
Requests return 401
Use:
Requests return a plain 404
Check the base URL.
It should not end in:
The router returns model_not_found
Compare the configured alias with:
- capitalization
- punctuation
- served-model alias
- agent
--model - API-key model access
- agent health
The backend returns 404 for /v1/messages
The backend does not implement the Anthropic Messages endpoint.
A backend that supports only:
Text works but tools fail
Check that:- the model supports structured tool calls
- vLLM uses
--enable-auto-tool-choice - the selected
--tool-call-parsermatches the model - the backend returns Anthropic-format tool-use blocks
- the model follows tool schemas reliably
The backend rejects system messages
Upgrade the backend and test the current Claude Code request against it directly.
Do not begin by pinning an old Claude Code release. First confirm whether the backend’s current Anthropic Messages implementation accepts the system-content shape the client sends.
The backend rejects thinking or adaptive
Update the backend first.
As a compatibility test:
The backend rejects beta fields
As a temporary diagnostic:Claude Code retries and Hivenet Router later reports no eligible agent
Inspect the backend’s first error. A backend rejection that Hivenet Router treats as retryable can cause the request session to try other agents and exclude agents that already failed. Check:- Router
- Agent
- vLLM
Streaming arrives only after completion
Check:- backend SSE behavior
- Hivenet Router agent version
- reverse-proxy buffering
- proxy read and idle timeouts
- response
Content-Type
Token counting fails
Test the backend directly:The model picker does not show Hivenet Router models
Use the mapped aliases:claude or anthropic.
Next steps
OpenCode
Connect a coding agent through OpenAI Chat Completions.
Use from code
Call Hivenet Router from SDKs, scripts, and custom applications.
Chat completions and messages
Review the Anthropic and OpenAI inference paths.
API keys
Configure model access, quotas, expiration, and credential rotation.
vLLM agent
Deploy and register the backend serving Claude Code requests.
Audit logging
Investigate Claude Code requests by tenant, model, status, and agent.

