🧠 Choosing a model
Sonnet is the default. For a hard task type /model opus, then /model sonnet to switch back. Opus uses your balance faster.
Setup guide
Claude Code is Anthropic's coding tool for the terminal and VS Code. It normally needs a Claude subscription or an Anthropic API account. This guide connects Claude Code to your KMYAI key so it runs on your token balance and you pay only for what you use.
On Windows open PowerShell and run:
irm https://claude.ai/install.ps1 | iexOn macOS or Linux, in Terminal:
curl -fsSL https://claude.ai/install.sh | bashIf you have Node.js 18 or newer you can also install it with npm:
npm install -g @anthropic-ai/claude-codeClose and reopen your terminal afterwards. If “claude --version” prints a version, the install worked.
Create a KMYAI account, add tokens and create a key on the “VS Code / API” page. The key starts with kmy-sk-.
The command below writes Claude Code's settings file. Replace YOUR_KMYAI_KEY with your own key. In the app, the API page shows this command pre-filled with your key.
Windows (PowerShell):
New-Item -ItemType Directory -Force "$HOME\.claude" | Out-Null
@'
{
"env": {
"ANTHROPIC_BASE_URL": "https://kmyai.cloud/api",
"ANTHROPIC_AUTH_TOKEN": "YOUR_KMYAI_KEY",
"ANTHROPIC_MODEL": "claude-sonnet-5-5",
"ANTHROPIC_DEFAULT_OPUS_MODEL": "claude-opus-5-5",
"ANTHROPIC_DEFAULT_SONNET_MODEL": "claude-sonnet-5-5",
"ANTHROPIC_DEFAULT_HAIKU_MODEL": "claude-haiku-4-5",
"ANTHROPIC_SMALL_FAST_MODEL": "claude-haiku-4-5",
"CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC": "1"
}
}
'@ | Set-Content -Encoding utf8 "$HOME\.claude\settings.json"macOS / Linux:
mkdir -p ~/.claude && cat > ~/.claude/settings.json <<'EOF'
{
"env": {
"ANTHROPIC_BASE_URL": "https://kmyai.cloud/api",
"ANTHROPIC_AUTH_TOKEN": "YOUR_KMYAI_KEY",
"ANTHROPIC_MODEL": "claude-sonnet-5-5",
"ANTHROPIC_DEFAULT_OPUS_MODEL": "claude-opus-5-5",
"ANTHROPIC_DEFAULT_SONNET_MODEL": "claude-sonnet-5-5",
"ANTHROPIC_DEFAULT_HAIKU_MODEL": "claude-haiku-4-5",
"ANTHROPIC_SMALL_FAST_MODEL": "claude-haiku-4-5",
"CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC": "1"
}
}
EOFThis overwrites ~/.claude/settings.json. If you already have custom settings, open the file and add only the “env” block.
cd your-project
claudeOn first launch you get theme and folder-trust prompts. Answer Yes to “Do you want to use this API key?”. If a login screen appears, the settings file was not read — check step three.
To verify the connection type /status inside Claude Code: the Base URL should be the KMYAI address.
Sonnet is the default. For a hard task type /model opus, then /model sonnet to switch back. Opus uses your balance faster.
Type /clear for every new task. Accumulated history is resent on every step, so a clean session is the biggest saving.
The official Claude Code extension for VS Code reads the same settings file. Install it and restart VS Code.
KMYAI trims the old file contents and command output Claude Code keeps resending and uses caching, so long sessions use fewer tokens.
| Symptom | Cause and fix |
|---|---|
| A login screen opens | The settings file is in the wrong place or the JSON is invalid. On Windows the path is C:\Users\YOU\.claude\settings.json. |
| 401 authentication_error | The key is wrong or was regenerated. Create a new key and put it in the settings file. |
| 402 billing_error | Your balance ran out. Add tokens to your account. |
| You previously logged in with an Anthropic account | Type /logout in Claude Code, then close and reopen it. |
| Model not found | The model names in the settings file must match models enabled on KMYAI; current names are listed at the bottom of the API page. |
Yes. Claude Code also works with an API base URL and key. With the settings in this guide it uses your KMYAI key and usage comes out of your token balance.
More than chat, because it resends project files and history on every step. Keeping Sonnet as the default, typing /clear for new tasks and leaving KMYAI's optimization on reduces usage noticeably.
Sonnet is enough for most day-to-day work. Switch to Opus for large refactors and hard bugs, and use Haiku for small jobs.
Yes. The official Claude Code extension uses the same ~/.claude/settings.json file.
Windows, macOS and Linux. The install commands in this guide cover all three.
Create a free account, add tokens and start working with the best models.