Claude Code
Claude Code can go through a gateway instead of a claude.ai account: it reads the API address and the key from two environment variables. Once set up, you use it exactly as usual.
What you need
Section titled “What you need”- A Kloria key, ideally dedicated to Claude Code (see Quickstart).
- macOS 13+, Windows 10+ or a recent Linux distribution.
-
Install Claude Code
Fenêtre de terminal curl -fsSL https://claude.ai/install.sh | bashFenêtre de terminal irm https://claude.ai/install.ps1 | iexGit for Windows is recommended so Claude Code can use Bash. Without it, it uses PowerShell.
Open a new terminal and check with
claude --version. If it’s already installed, skip to the next step. -
Point Claude Code at Kloria
Open (or create) your user settings file:
- macOS / Linux:
~/.claude/settings.json - Windows:
%USERPROFILE%\.claude\settings.json
Add the following
envblock, with your key instead ofsk-…:~/.claude/settings.json {"env": {"ANTHROPIC_BASE_URL": "https://api.kloria.dev","ANTHROPIC_AUTH_TOKEN": "sk-…","ANTHROPIC_DEFAULT_OPUS_MODEL": "claude-opus-5-5","ANTHROPIC_DEFAULT_SONNET_MODEL": "claude-sonnet-5","ANTHROPIC_DEFAULT_HAIKU_MODEL": "claude-sonnet-5"}}If the file already has other settings, just add the
envkey next to them. - macOS / Linux:
-
Start Claude Code and check
In your project folder:
Fenêtre de terminal claudeType
/status: the Anthropic base URL line should showhttps://api.kloria.dev, and an Auth token line should mentionANTHROPIC_AUTH_TOKEN. Close the menu and send a message: a normal reply confirms everything goes through Kloria.
Why these variables
Section titled “Why these variables”| Variable | Role |
|---|---|
ANTHROPIC_BASE_URL |
Sends requests to Kloria instead of Anthropic. No /v1: Claude Code adds it. |
ANTHROPIC_AUTH_TOKEN |
Your Kloria key, sent in the Authorization: Bearer header. It takes precedence over an existing claude.ai login. |
ANTHROPIC_DEFAULT_OPUS_MODEL |
The model used when you pick “Opus” in /model. |
ANTHROPIC_DEFAULT_SONNET_MODEL |
The model used for “Sonnet”, the default choice. |
ANTHROPIC_DEFAULT_HAIKU_MODEL |
The model used for “Haiku” and for background tasks (session titles, summaries). |
Switching models
Section titled “Switching models”- During a session:
/model, then pick Opus or Sonnet. Aliases are resolved by the variables above. - At launch:
claude --model claude-opus-5-5. - For a one-off session, you can also set
ANTHROPIC_MODELto the model ID you want.
Available IDs are on Models and pricing.
Keeping the key out of the settings file
Section titled “Keeping the key out of the settings file”If you’d rather not write the key in settings.json, keep ANTHROPIC_BASE_URL and the models in the file, remove ANTHROPIC_AUTH_TOKEN, and export it in your shell before starting claude:
read -s ANTHROPIC_AUTH_TOKEN && export ANTHROPIC_AUTH_TOKENclaude$s = Read-Host "Kloria key" -AsSecureString$env:ANTHROPIC_AUTH_TOKEN = [System.Net.NetworkCredential]::new("", $s).PasswordclaudeA variable exported in the shell only applies to that terminal and the programs started from it. Never put the key in a project’s .claude/settings.json: that file is shared with the repository.
What changes compared with a claude.ai account
Section titled “What changes compared with a claude.ai account”Through a gateway, Claude Code turns off features tied to a claude.ai account: Remote Control, voice dictation and fast mode (/fast). Everything else (agents, MCP, hooks, plugins, plan mode) works normally.
Your claude.ai login, if you have one, stays saved but unused while ANTHROPIC_AUTH_TOKEN is set. Remove the variable to go back to your account.
Useful options
Section titled “Useful options”| Variable | When to add it |
|---|---|
CLAUDE_CODE_DISABLE_EXPERIMENTAL_BETAS = 1 |
If you get 400 errors mentioning anthropic-beta, context_management or “Extra inputs are not permitted”. |
CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC = 1 |
To turn off telemetry and version checks. It also disables auto-updates: run claude update from time to time. |
CLAUDE_CODE_SUBAGENT_MODEL |
To force a model for subagents, for example claude-sonnet-5 while the main session runs on Opus. |
All of these go in the same env block of the settings file.
Not working?
Section titled “Not working?”| Symptom | Check |
|---|---|
| Claude Code asks you to log in to claude.ai | The key isn’t read. Make sure ANTHROPIC_AUTH_TOKEN is in ~/.claude/settings.json (not a project file) and that the JSON is valid: claude doctor reports it. |
/status doesn’t show api.kloria.dev |
ANTHROPIC_BASE_URL isn’t applied. Same check as above. |
| 401 error | The key is invalid, disabled or expired. Check it in the console, or create a new one. |
| 403 error mentioning “quota” | Your balance or the key’s quota is used up. See Credits and billing. |
| Startup warning about two authentication sources | A claude.ai login exists alongside the key. /logout removes it, the Kloria key stays. |
More cases on the Troubleshooting page.