Claude Code CLI can connect to Nbility through the Anthropic Messages-compatible API. This guide follows Anthropic's current setup and LLM gateway documentation.
Prerequisites
- Create an active key on Token Management.
- Check Models to ensure the key's group can use the target Claude model.
- Never commit a real key or include it in screenshots and chat logs.
Completion path: create the key → configure Claude Code → send a short test message → confirm the request in Usage Logs.
Install Claude Code
The native installer is recommended on macOS, Linux, and WSL:
curl -fsSL https://claude.ai/install.sh | bash
Windows PowerShell:
irm https://claude.ai/install.ps1 | iex
Homebrew and WinGet are also supported:
brew install --cask claude-code
winget install Anthropic.ClaudeCode
Configure the current shell
export ANTHROPIC_BASE_URL="https://api.nbility.ai"
export ANTHROPIC_AUTH_TOKEN="YOUR_API_KEY"
export ANTHROPIC_MODEL="claude-sonnet-4-6"
Then start Claude Code from a project:
claude
Do not append /v1 to ANTHROPIC_BASE_URL; Claude Code adds /v1/messages. ANTHROPIC_AUTH_TOKEN is sent as Authorization: Bearer ..., which matches Nbility gateway authentication.
Persist non-secret settings
Store non-secret settings in ~/.claude/settings.json and inject the token through the process environment:
{
"env": {
"ANTHROPIC_BASE_URL": "https://api.nbility.ai",
"ANTHROPIC_MODEL": "claude-sonnet-4-6",
"CLAUDE_CODE_ENABLE_GATEWAY_MODEL_DISCOVERY": "1"
}
}
CLAUDE_CODE_ENABLE_GATEWAY_MODEL_DISCOVERY=1 lets recent Claude Code versions populate /model from the gateway's /v1/models endpoint. Availability still depends on the key's group and Nbility's current catalog.
Verify and troubleshoot
Run /status and /model after startup. Confirm that the endpoint and model are correct.
401: ensureANTHROPIC_AUTH_TOKENis available in the same shell that started Claude Code.404or a duplicated path: usehttps://api.nbility.aiwithout/v1.- Missing model: check Models, the key group, and gateway model discovery.
- A subscription login still exists: this is expected.
ANTHROPIC_AUTH_TOKENtakes precedence over subscription OAuth until you unset it.
Tip: Token Management also offers CC-Switch import. After importing, use
/statusto verify the effective authentication method and model.