Skip to main content

Use InferNode from Claude Code

Claude Code uses the Anthropic Messages format. To work with InferNode's Chat Completions API, this recipe uses Claude Code Router as a local translator: Claude Code connects to the router, which calls InferNode with your key. It does not use LiteLLM.

Tested with Claude Code 2.1.314 and Claude Code Router 3.1.3: generation and file reading through tools with Saptiva Turbo, Saptiva Omni, and Saptiva Cortex. These are three independent aliases. Anthropic does not officially support integration with non-Claude models; these tests do not cover every agent feature.

Before you start​

You need Claude Code installed, Node.js 22 or later, Python 3, jq, an InferNode key, and your installation URL. Commands use Bash; run bash if your terminal uses another shell. Install the tested router version:

npm install -g @musistudio/claude-code-router@3.1.3
claude --version

Use a dedicated terminal for this connection. The variables you will set change the Claude Code provider in that terminal and in processes you start from it.

1. Verify InferNode and the aliases​

Replace the example domain. Paste the key when prompted; it is hidden and is not written to shell history:

export INFERNODE_BASE_URL='https://api.<tu-dominio>/infernode/v1'
read -r -s -p 'InferNode API key: ' INFERNODE_API_KEY
printf '\n'
export INFERNODE_API_KEY
curl --fail-with-body -sS "$INFERNODE_BASE_URL/me" \
-H "Authorization: Bearer $INFERNODE_API_KEY"

Query the catalog before configuring the router:

curl --fail-with-body -sS "$INFERNODE_BASE_URL/models/aliases" \
-H "Authorization: Bearer $INFERNODE_API_KEY" \
| jq '.data[] | {alias, model: .model.id, context: .model.context_window}'

Copy the exact aliases, including capitalization and spaces. The physical model and its limits may change behind each alias. If your installation does not offer one of them, omit it from the examples. To confirm access, the GET /v1/me query should return your user and organization.

2. Configure a new local router​

This step is for a new Claude Code Router installation. If you already use it and ~/.claude-code-router/config.sqlite exists, add the provider through its management interface and keep your current providers. Create or retrieve a gateway access token there and save it in ~/.config/saptiva/router-token, with 600 permissions. With the router running, skip the rest of this step and continue to step 3; adjust ANTHROPIC_BASE_URL if your gateway uses another port. Do not replace the database or expect editing the initial file to change an already imported configuration.

Create a private token for the connection between Claude Code and the router. It is separate from your InferNode key:

umask 077
mkdir -p ~/.config/saptiva ~/.claude-code-router
if [ ! -s ~/.config/saptiva/router-token ]; then
python3 -c 'import secrets; print(secrets.token_urlsafe(32))' \
> ~/.config/saptiva/router-token
fi
chmod 600 ~/.config/saptiva/router-token
export SAPTIVA_ROUTER_TOKEN="$(cat ~/.config/saptiva/router-token)"

Create ~/.claude-code-router/config.json with the following content, without replacing a file you already use:

~/.claude-code-router/config.json
{
"HOST": "127.0.0.1",
"PORT": 3456,
"APIKEY": "${SAPTIVA_ROUTER_TOKEN}",
"Providers": [
{
"name": "infernode",
"api_base_url": "${INFERNODE_BASE_URL}",
"api_key": "${INFERNODE_API_KEY}",
"models": [
"Saptiva Turbo",
"Saptiva Omni",
"Saptiva Cortex"
],
"autoFetchModels": false,
"capabilities": [
{
"type": "openai_chat_completions",
"baseUrl": "${INFERNODE_BASE_URL}"
}
],
"account": {
"enabled": false
}
}
],
"preferredProvider": "infernode",
"Router": {
"builtInRules": {
"claude-code": {
"enabled": false
},
"codex": {
"enabled": false
}
},
"fallback": {
"mode": "off",
"models": [],
"retryCount": 0
},
"rules": []
},
"profile": {
"enabled": false,
"profiles": []
},
"observability": {
"requestLogs": false,
"agentAnalysis": false
}
}

On its first startup, version 3.1.3 imports this file, resolves environment variables, and saves the configuration in SQLite. All three values must be exported in that terminal: INFERNODE_BASE_URL, INFERNODE_API_KEY, and SAPTIVA_ROUTER_TOKEN. The router stores credentials locally; treat its directory as private.

The configuration declares one provider, keeps aliases separate, disables automatic rules and fallback alternatives, and prevents the router from modifying your agents' global configuration. It listens only on 127.0.0.1.

Start it from the same terminal:

ccr start --no-open

The gateway address is http://127.0.0.1:3456. Management uses http://127.0.0.1:3458 by default. The command displays a management URL containing a token: do not share it. If you change the InferNode key or URL after import, update the provider in the router's management interface.

3. Show the aliases in Claude Code​

Create ~/.config/saptiva/claude-models.json so /model displays the three exact names:

~/.config/saptiva/claude-models.json
{
"modelPicker": {
"replaceBuiltInOptions": true,
"options": [
{
"model": "Saptiva Turbo",
"label": "Saptiva Turbo"
},
{
"model": "Saptiva Omni",
"label": "Saptiva Omni"
},
{
"model": "Saptiva Cortex",
"label": "Saptiva Cortex"
}
]
}
}

From your project directory, configure the connection and open a session:

unset ANTHROPIC_API_KEY ANTHROPIC_MODEL ANTHROPIC_DEFAULT_FABLE_MODEL
export ANTHROPIC_BASE_URL='http://127.0.0.1:3456'
export ANTHROPIC_AUTH_TOKEN="$(cat ~/.config/saptiva/router-token)"
export ANTHROPIC_DEFAULT_HAIKU_MODEL='Saptiva Turbo'
export ANTHROPIC_DEFAULT_SONNET_MODEL='Saptiva Omni'
export ANTHROPIC_DEFAULT_OPUS_MODEL='Saptiva Cortex'
export ANTHROPIC_SMALL_FAST_MODEL='Saptiva Turbo'
export CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC=1
export DISABLE_PROMPT_CACHING=1
export CLAUDE_CODE_MAX_OUTPUT_TOKENS=8192
export CLAUDE_CODE_MAX_CONTEXT_TOKENS=131072

claude --settings ~/.config/saptiva/claude-models.json --model 'Saptiva Turbo'

You can replace Saptiva Turbo with Saptiva Omni or Saptiva Cortex. Within the session, /model lets you switch between them. The family variables only select which alias to use when Claude Code internally requests Haiku, Sonnet, or Opus; they do not turn InferNode models into Anthropic models.

Do not set ANTHROPIC_MODEL permanently. It can make a new session return to a different model from the one you saved with /model. In this example, --model selects the model for that launch; if you omit it, Claude Code reads its saved configuration. Do not configure Fable mappings for these aliases.

The 131072 context limit is conservative for switching between the three aliases in this example. Check the catalog before adjusting it. The 8192 output limit also occupies space within that window. Disabling prompt caching avoids relying on Anthropic cache compatibility; the Prompt caching off warning is expected and does not indicate another provider is being used.

The commands claude-saptiva, pi-saptiva, and opencode-saptiva are not part of these tools: they exist only if your team installed custom launchers. This guide uses standard commands.

4. Test text and tools​

Make a short request with the previous step's variables loaded:

claude --settings ~/.config/saptiva/claude-models.json \
--model 'Saptiva Turbo' --print 'Responde solamente OK.' \
--max-turns 1 --tools ''

Then, in the interactive session, ask it to read a small existing file by its exact path and summarize it without modifying it. Keep normal tool confirmations enabled. A text response alone does not verify that the agent can use tools.

Check which model responded​

The name shown in /model is the requested model. The answer to “which model are you?” is not evidence of which model served the request: Claude Code includes instructions presenting it as Anthropic's assistant, and the model may repeat them or invent a family.

To query an alias's current resolution, use GET /v1/models/aliases. To check an inference, inspect the model field in the InferNode response:

curl --fail-with-body -sS "$INFERNODE_BASE_URL/chat/completions" \
-H "Authorization: Bearer $INFERNODE_API_KEY" \
-H 'Content-Type: application/json' \
-d '{"model":"Saptiva Turbo","messages":[{"role":"user","content":"Responde OK."}],"max_tokens":512}' \
| jq '{model, finish_reason: .choices[0].finish_reason, content: .choices[0].message.content}'

That direct test checks InferNode, but not a Claude Code session's route. For that session, compare your message timestamps with the provider, model, and HTTP status in the router's usage record. In version 3.1.3 you can query just those metadata fields, without opening credentials or conversation content:

python3 - <<'PYTHON'
from pathlib import Path
import sqlite3
path = Path.home() / ".claude-code-router/app-data/usage.sqlite"
with sqlite3.connect(path.as_uri() + "?mode=ro", uri=True) as db:
for row in db.execute(
"SELECT created_at, provider, model, status_code "
"FROM usage_events ORDER BY id DESC LIMIT 5"
):
print(*row, sep=" | ")
PYTHON

The created_at timestamps are in UTC. Expect provider infernode, the physical model behind the alias, and status_code equal to 200. If the provider or model does not match, review the router configuration before continuing. If you changed terminal variables, close Claude Code and open another session: an existing session retains its previous environment.

Common errors​

SymptomWhat to check
401 from the local routerANTHROPIC_AUTH_TOKEN must contain the router token, not the InferNode key.
Provider authentication errorUpdate the InferNode key saved in the router's provider.
Connection refused at 127.0.0.1:3456Run ccr start --no-open and check that the port is available.
model_not_foundUse the exact alias and verify it exists for your key. Do not add provider prefixes to the name sent to InferNode.
ANTHROPIC_MODEL is setRemove that variable from your launcher or terminal and open a new session. Also check the --model argument.
The model says it is Claude or FableCheck the records and the model field, not its self-description.
Claude account connectors are disabledThis session uses gateway authentication, which takes precedence over the account login.
The response is cut off or times outCheck output and context limits; try Saptiva Turbo and see InferNode is not responding.

To stop the router when you finish:

ccr stop

Next step​