With environment variables, Claude Code only talks to All in One AI in the terminal where you set them. To stop repeating them in every terminal, save them once in the Claude Code settings file, under the env key. From then on, just type claude.
Before you start
| 1 |
Create a key in the API Center with the ai:read and ai:write permissions. Use a sandbox_ key to check the setup without spending and a prod_ key to work. The fields are explained in creating an API key.
|
|
Which file to use
| File |
Who it applies to |
Can the key go here? |
| ~/.claude/settings.json |
Only you, in every project on this computer. On Windows it is %USERPROFILE%\.claude\settings.json. |
Yes. It is the file in this article. |
| .claude/settings.local.json |
Only you, in one project. |
Yes, if it stays out of Git. When Claude Code creates it, it takes care of that. If you create it by hand, add it to .gitignore. |
| .claude/settings.json |
The whole project team, because it goes into the repository. |
No. Anyone who clones the repository gets your key. |
1. Create the folder and open the file
On Linux and macOS:
mkdir -p ~/.claude
nano ~/.claude/settings.json
On Windows, in PowerShell:
New-Item -ItemType Directory -Force "$HOME\.claude"
notepad "$HOME\.claude\settings.json"
If Notepad asks whether to create the file, answer yes. If the file already exists, do not delete what is in it: Claude Code writes to it too, for example when you change the theme.
2. Paste the env key and save
In an empty file, paste the whole block and replace prod_... with your key:
{
"env": {
"ANTHROPIC_BASE_URL": "https://api.mozout.co.mz",
"ANTHROPIC_AUTH_TOKEN": "prod_...",
"ANTHROPIC_MODEL": "moonshotai/kimi-k2.7-code",
"ANTHROPIC_DEFAULT_HAIKU_MODEL": "deepseek-ai/deepseek-v4-flash",
"CLAUDE_CODE_MAX_CONTEXT_TOKENS": "262144",
"CLAUDE_CODE_MAX_OUTPUT_TOKENS": "16000",
"CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC": "1"
}
}
If the file already had other settings, add only the "env": { ... } part, inside the outer braces and separated from the rest by a comma. Numbers go in quotes, as text. Save: in Notepad, Ctrl+S; in nano, Ctrl+O, Enter and Ctrl+X.
|
The file is strict JSON: a // comment or a comma after the last item is an error. At start, Claude Code shows "Settings Error" and lets you fix the file, exit or carry on without it.
|
3. Open Claude Code and check
| 1 |
Close Claude Code, if it was open, and start it with claude. You do not need to export anything.
|
|
| 2 |
Type /status. The "Setting sources" line must show "User settings": that is your file.
|
|
| 3 |
Send a short question. To check without spending, put a sandbox_ key in the file first: the answer is always "Resposta de teste (sandbox)." Then replace it with the prod_ key.
|
|
The file wins over the terminal
When the same variable is in the terminal and in the file's env, the file value applies, according to the Claude Code documentation. So an export ANTHROPIC_MODEL=... in the terminal no longer changes the model. To use another model for one session only, start with claude --model zai-org/glm-5.2. To change it for good, edit the value in the file.
|
The key is written in the file. Claude Code copies the env values exactly as they are and does not read other variables, so "$MOZOUT_API_KEY" does not work here. Keep the file on your own computer only and never put it in a repository. If the key leaks, see what to do, in the right order.
|