KMYAIKMYAI
TürkçeLog inGet tokens

Setup guide

Set up Claude Code without a subscription, using your own key

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.

Setup

  1. Install Claude Code

    On Windows open PowerShell and run:

    PowerShell
    irm https://claude.ai/install.ps1 | iex

    On macOS or Linux, in Terminal:

    bash
    curl -fsSL https://claude.ai/install.sh | bash

    If you have Node.js 18 or newer you can also install it with npm:

    npm
    npm install -g @anthropic-ai/claude-code

    Close and reopen your terminal afterwards. If “claude --version” prints a version, the install worked.

  2. Get your KMYAI API key

    Create a KMYAI account, add tokens and create a key on the “VS Code / API” page. The key starts with kmy-sk-.

  3. Create the settings file

    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):

    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:

    bash
    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"
      }
    }
    EOF

    This overwrites ~/.claude/settings.json. If you already have custom settings, open the file and add only the “env” block.

  4. Run it

    Terminal
    cd your-project
    claude

    On 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.

🧠 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.

🧹 Use /clear

Type /clear for every new task. Accumulated history is resent on every step, so a clean session is the biggest saving.

🧩 VS Code extension

The official Claude Code extension for VS Code reads the same settings file. Install it and restart VS Code.

📉 Automatic savings

KMYAI trims the old file contents and command output Claude Code keeps resending and uses caching, so long sessions use fewer tokens.

Troubleshooting

SymptomCause and fix
A login screen opensThe 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_errorThe key is wrong or was regenerated. Create a new key and put it in the settings file.
402 billing_errorYour balance ran out. Add tokens to your account.
You previously logged in with an Anthropic accountType /logout in Claude Code, then close and reopen it.
Model not foundThe model names in the settings file must match models enabled on KMYAI; current names are listed at the bottom of the API page.

Frequently asked questions

Can I use Claude Code without a Claude Pro subscription?

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.

Does Claude Code use a lot of tokens?

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.

Which model should I use?

Sonnet is enough for most day-to-day work. Switch to Opus for large refactors and hard bugs, and use Haiku for small jobs.

Does it work in VS Code too?

Yes. The official Claude Code extension uses the same ~/.claude/settings.json file.

Which operating systems are supported?

Windows, macOS and Linux. The install commands in this guide cover all three.

Related pages

Get started

Create a free account, add tokens and start working with the best models.