What is Claude Code
Claude Code is Anthropic AI assistant for code. It supports only Claude models but can work through a custom gateway.
You can connect NormaHub as a provider and use Claude Opus, Sonnet, Fable and other models through the NormaHub API. Russian version: Подключение Claude Code.
1. Get an API key
Create an API key in the NormaHub dashboard. Copy it once — it is not shown again. Create a dedicated key with its own limit for Claude Code: an agent makes dozens of requests per session, and a shared unlimited key is an open budget.
2. One-minute quick start
Skip settings.json for the check: set two variables in the current terminal and run claude. If the agent answers through NormaHub, the base works and you can make the setup permanent. Important: the address has no trailing /v1.
# Linux/macOS — verify in a minute without editing settings.json
export ANTHROPIC_BASE_URL="https://api.normahub.cc"
export ANTHROPIC_API_KEY="your_api_key"
claude# Windows (PowerShell)
$env:ANTHROPIC_BASE_URL = "https://api.normahub.cc"
$env:ANTHROPIC_API_KEY = "your_api_key"
claude3. Find the Claude Code config
Configuration lives in:
- Linux/macOS:
~/.claude/settings.json - Windows:
%USERPROFILE%\.claude\settings.json
If the file does not exist, create it together with the ~/.claude/ directory.
4. Configure settings.json
Open or create settings.json and add:
{
"env": {
"ANTHROPIC_BASE_URL": "https://api.normahub.cc",
"ANTHROPIC_AUTH_TOKEN": "your_api_key",
"CLAUDE_CODE_ENABLE_GATEWAY_MODEL_DISCOVERY": "1",
"CLAUDE_CODE_DISABLE_1M_CONTEXT": "1"
},
"model": "claude-sonnet-4-6"
}Replace your_api_key with the real dashboard key.
ANTHROPIC_BASE_URL— NormaHub API address (no /v1)ANTHROPIC_AUTH_TOKEN— your API keyCLAUDE_CODE_ENABLE_GATEWAY_MODEL_DISCOVERY— loads models from the gatewayCLAUDE_CODE_DISABLE_1M_CONTEXT— disables synthetic [1m] suffixesmodel— default model
5. Restart and verify
Fully restart Claude Code after saving, then send a test request. If configured correctly, the answer comes from the selected model through NormaHub. Prefer the install script if you do not want to configure manually.
6. Model list file (optional)
To help Claude Code see the NormaHub models, create ~/.claude/cache/gateway-models.json with the IDs you use (example — take exact IDs from the catalog):
{
"data": [
{ "id": "claude-opus-4-6" },
{ "id": "claude-sonnet-4-6" },
{ "id": "claude-fable-5-1" }
]
}Keep this file in sync with the catalog: stale IDs produce model-not-found errors while the connection itself is fine.
7. Switching models
ANTHROPIC_BASE_URL changes where requests go, not which model answers — the model still has to be selected. Priority order: /model in session first, then claude --model, then ANTHROPIC_MODEL, then the model field in settings.json. Through a gateway Claude Code passes any model string through without checking it, so a typo surfaces only on the first request.
Aliases such as sonnet, opus, and haiku resolve per provider; for reproducible sessions pin the full model ID in settings.json instead of an alias.
8. Precedence and status check
When the same variable exists in both the shell and the settings.json env block, the settings file value applies. Either way the values are read at startup: export them in the same terminal you run claude from, then restart the process completely. Run /status inside Claude Code to confirm which settings source is active, and claude update to stay on a version that supports your selected model.
How much an agent session costs
Claude Code on your own key is pay-as-you-go with no subscription: zero activity means zero spend, an active session bills every token of file context, tools and answers at the model rate. So match the model to the task: Sonnet for daily work, Opus for heavy refactors, smaller models for routine. Exact input/output prices are in the catalog, the formula in the token cost guide. Balance melts faster than it looks: check request history after the first sessions.
Common errors
- 401 Unauthorized — invalid or revoked API key
- 402 Payment Required — insufficient balance
- 403 Forbidden — model unavailable to your key
- 429 Too Many Requests — rate or spend limit exceeded
- 503 Service Unavailable — model provider temporarily down
- This account requires login — gateway variables not visible in this terminal; export them in the same shell and restart
- Auth fails with /v1 in the base — ANTHROPIC_BASE_URL must have no /v1 suffix, unlike Cursor and the OpenAI SDK
On errors check balance and available models in the dashboard.