To use Hivenet Router as a Claude Code custom endpoint, set ANTHROPIC_BASE_URL to your Router’s HTTPS origin and ANTHROPIC_AUTH_TOKEN to a Router client key. Map the CLI’s model aliases to a model that your key can access. Start Claude Code from that terminal and run /status to check the endpoint and credential source.
Claude Code sends inference requests to POST /v1/messages. Router forwards each request to an eligible model server. If your local model already answers chat requests, check which API handled them. An OpenAI Chat Completions response tells you nothing about whether the same server accepts Anthropic Messages or returns the structured tool calls a coding session needs.
This guide starts with an existing, authenticated Router deployment and a model backend that supports structured tool use. It covers the client connection and common setup failures. Use the LLM routing overview for the broader architecture and the OpenCode guide if you want that client's OpenAI-compatible provider setup.
Compatibility boundary: Anthropic documents gateway connections but does not support using Claude Code with non-Claude models through gateways. Hivenet's documented integration is not a promise of Anthropic support or identical behavior across models. The setup below was checked against current documentation on November 19, 2026; it was not run against a deployed Router and model.
A custom endpoint is the API address Claude Code uses for model requests in place of its default address. In this setup the address belongs to Hivenet Router. The developer configures the terminal client once, and the Router operator controls which registered models the client key can reach.
Use HTTPS for the connection. Both the bearer credential and the model request travel to the host named in the base URL, so confirm that host with the operator before supplying a key. Router can apply the key’s model restrictions and rate limits to those API calls. To investigate a failure, give the operator the request ID and selected model. Keep the prompt, repository contents, and token out of the support message.
The request path is Claude Code, your Router endpoint, a selected agent, and the model server. Router forwards the Messages request to the backend. It does not convert an OpenAI Chat Completions endpoint into an Anthropic Messages endpoint. The Router integration reference describes this arrangement.
Before configuring the client, have these pieces ready:
llm capability.POST /v1/messages and supports the model's tool-call format.vLLM documents a Claude Code integration, including the need for a tool-capable model and suitable tool-call configuration. Choose the parser and chat template for your model and vLLM version. Installing a server that exposes the endpoint does not establish that the model will use tools reliably.
Use a short served-model name, such as router-code-model, consistently in the backend, agent registration, client configuration, and key permissions. This is a placeholder for your deployed model, not a model available from Hivenet by that name. The vLLM integration guidance recommends avoiding slash-containing model names for this client path.
Anthropic's gateway compatibility reference lists /v1/messages/count_tokens as optional. Without it, Claude Code can use an approximate context count. Router documents forwarding that path too, but the selected backend must implement it. Do not make token counting a prerequisite for the first connection.
Start with one terminal session. That makes it easier to see which configuration the client receives before introducing persistent settings. This example assumes your secret-management process has already made the raw Router client key available as HIVENET_ROUTER_API_KEY.
Replace https://router.example.com with your Router address. Use the origin without /v1: Claude Code adds the API path itself. Replace router-code-model with the same served-model name throughout.
ANTHROPIC_AUTH_TOKEN sends the credential in an Authorization: Bearer header, which Router accepts. ANTHROPIC_API_KEY sends an x-api-key header instead. Clearing that variable in this session avoids mixing a separate Anthropic key into the setup. See Anthropic's gateway connection instructions for credential selection.
The three alias mappings deliberately point to one model for this first connection. Choosing sonnet will request your configured model; it does not turn that model into Claude Sonnet. Map the background haiku alias as well, so the client is not left requesting a model your deployment does not serve. Later, you can assign different served models to these aliases if each supports the required requests.
Use the same key and model for the direct check and the client. First confirm that the model appears in GET /v1/models for that key. Then send a short Messages request through Router. The Router API reference covers both the Messages format and the backend endpoint requirement.
These commands use Bash and a current curl installation. On Windows, run this section in WSL or another Bash environment after setting the Bash variables above. The 120-second timeout is an example upper bound for this check, not a performance target.
Compare the model ID returned by the catalog with the name you put in the JSON request. A typo here can make authentication look like the problem even when the key works. Look for an Anthropic-format message response with a content array, rather than an OpenAI choices response. Inspect any returned error before proceeding. The explicit max_tokens field is part of the Messages request; leaving it out can produce a backend rejection.
A successful response establishes a basic text path for this request. It does not establish streaming, tool execution, large-context behavior, or support for every field Claude Code may send.
From the configured terminal, start:
Run /status. Check that the base URL is your Router address and that the active credential source is ANTHROPIC_AUTH_TOKEN. Confirm the intended model mapping, then send a short prompt. Shell variables affect processes launched from that shell; an already-open editor or a terminal without those variables can use different settings.
For a small coding check, create a disposable folder containing a short README.md. Ask the client to read and summarize it, with no file changes. Review any tool permission request before approving it, and confirm that the answer reflects the file. A model can produce plausible prose while failing to make the structured tool call the task needs.
If you later test edits or commands, use a throwaway project and inspect what changed. Keep tool permissions in the client. Router controls access to inference; it does not decide whether the coding agent may edit a local file or run a shell command. Our tool-calling guide explains that separation.
Shell exports last for the terminal session. To reuse the same endpoint across projects, edit the env object in your user settings file, ~/.claude/settings.json. On Windows the default location is %USERPROFILE%\.claude\settings.json. Merge the values into any existing settings so you keep your other preferences. See the Claude Code settings reference.
For example, a developer who uses the same Router model in several repositories could save these non-secret values:
Keep supplying the bearer token through your secret-management process when starting a new terminal. For a personal override in one repository, use .claude/settings.local.json. If you create that file yourself, add it to .gitignore. The similarly named .claude/settings.json is shared project configuration and can be committed. Keep credentials out of both files.
This article covers the terminal client. The VS Code extension and Claude Desktop have their own configuration paths, described in Anthropic's connection documentation. Do not assume that a successful terminal export configures every Claude Code surface.
Use a dedicated Router API key for the Claude Code CLI. Keep it out of version control and frontend code. If a key appears in a commit or shared diagnostic log, revoke it, issue a replacement, and update the credential source before starting a new terminal session. A separate key lets you do that without also rotating the credentials used by your chat interface.
For a shared Router deployment, give the client an identifiable key with the model access and quotas it needs. That allows its access to be changed without reusing an administration credential. Use our Router security guide and rate limits and quotas guide for the server-side controls.
Compare the same model and credential at each step: backend, Router request, then Claude Code. A failure through the client alone calls for a different check from a backend that rejects the basic Messages request.
To check streaming, repeat the same Messages request with "stream": true in the JSON body and add --no-buffer to curl. Watch for events arriving as the answer is generated. If events arrive progressively through Router but Claude Code displays the full answer at once, investigate the client. If both buffer output, compare the backend and proxy paths.
Streaming depends on the complete path carrying events progressively. Use the existing LLM streaming guide for that topic. For a Router-side failure, retain the request ID and use the monitoring and troubleshooting guide to locate the matching event. Keep credentials and private source content out of shared diagnostics.
Claude Code's request format evolves. Anthropic's compatibility reference describes endpoint and header requirements, including anthropic-version and anthropic-beta. A backend may accept a simple prompt yet reject a newer reasoning or context-management option. Follow its supported configuration for the installed versions rather than treating the first successful response as full feature compatibility.
For this Router setup, use the HTTPS origin, such as https://router.example.com. Claude Code appends /v1/messages itself. When you send the request directly with curl, specify the full endpoint. If the proxy log shows /v1/v1/messages, remove the extra path from the client configuration and restart the session.
Usually not. An active ANTHROPIC_AUTH_TOKEN takes precedence for the gateway connection while the saved account login can remain on the machine. Use /status to confirm what is active. Signing out is a separate choice, not a required step in this guide.
Setting the inference endpoint does not establish where every update check, integration, or tool request goes. Review the client's enabled features and outbound network policy for your environment. Keep that decision separate from whether the model request reaches Router.
Only if it also implements the Messages endpoint and the request behavior this client needs. For clients that use OpenAI Chat Completions, see the OpenCode guide above or the Pi custom provider guide for Pi’s models.json setup.
No. The alias requests the model you configured and actually serve. It does not change that model's identity, abilities, license, or support arrangements. Evaluate the coding tasks you need on that model before relying on the setup for your daily work.
Pick one AI, compute, or storage workload and see the difference for yourself. Spin it up in minutes, or let our team map your fastest path to production.