Skip to content

Install Claude Code and Choose Login or API Key

Updated · TokenomixAI

Install Claude Code in two stages: put the CLI on the machine, then choose account login or an API key through ANTHROPIC_BASE_URL. The sections below cover macOS, Linux and Windows, the one-command setup script, the settings file it edits, and the checks that confirm the configuration works.

Install Claude Code from Anthropic's official package, then pick authentication: account login or an API key with a gateway base URL written without /v1, and verify with a first session plus a quota check.

What you need before you install Claude Code

Claude Code is Anthropic's terminal coding agent. The CLI package comes from the official documentation at docs.anthropic.com. This guide covers the step after installation: pointing Claude Code at the model provider whose key is in hand.

TokenomixAI issues one API key in the sk-tkx-... format that covers many text and code models. No account and no credit card are required: buy a package on the website, pay with QRIS (Indonesia) or USDT, and the key is sent after payment.

  • A terminal on macOS or Linux, or PowerShell on Windows
  • An API key if the gateway path is used instead of account login
  • An internet connection for the first model request

Install Claude Code on macOS and Linux

With the CLI in place, the setup script is one command. It writes ANTHROPIC_BASE_URL and ANTHROPIC_AUTH_TOKEN into the env block of ~/.claude/settings.json, makes a backup first, and keeps the other settings already in that file.

bash <(curl -fsSL https://tokenomixai.com/install/claude.sh)

The script asks for the API key, and the key is never put in a URL. For Claude Code the base URL is https://api.tokenomixai.com without /v1, because Claude Code appends /v1/messages itself when it calls the API.

Install Claude Code on Windows with PowerShell

On Windows the same setup runs in PowerShell. The script writes the env block into %USERPROFILE%\.claude\settings.json and makes a backup before changing the file.

irm https://tokenomixai.com/install/claude.ps1 | iex

The exact file path and the env block it holds are described in Claude Code on Windows. Anything else about what the script does is documented in the docs.

Account login or an API key through ANTHROPIC_BASE_URL

Claude Code accepts two credential sources. Account login uses Anthropic's subscription session, while an API key uses a custom base URL plus an auth token. A session uses one of them, not both.

AspectAccount loginAPI key through a gateway
Credentialsaccount session at claude.aiANTHROPIC_AUTH_TOKEN holding the API key
Base URLdefault, unchangedhttps://api.tokenomixai.com without /v1
How you paysubscription on the accountbuy a package on the website, pay with QRIS or USDT
Quota unitfollows the account plantokens, not time windows

On the API key path, ANTHROPIC_AUTH_TOKEN holds the sk-tkx-... key and the base URL is written without /v1. A 401 response points at the token value or at a token from another provider left in the same env block. Anthropic base URL and auth token lists every field.

Check that Claude Code runs correctly

Environment variables are read when a process starts, so a new terminal is needed before any test.

  1. Open a new terminal and go into the project folder
  2. Run Claude Code and request one small task, such as reading a single file
  3. A 401 response means the ANTHROPIC_AUTH_TOKEN value and the base URL need to be checked
  4. A 429 response means the rate limit was reached, and Retry-After shows how long to wait

The quota endpoint answers with status, remainingTokens, maxTokens, usagePercent, expiresAt and low, which is true at 10 percent or less.

curl https://api.tokenomixai.com/v1/quota -H "Authorization: Bearer sk-tkx-..."

Quota is counted in tokens, not time windows, so there is no 5-hour limit while tokens remain and the key has not expired. A rate limit of 600 requests per minute per account applies, shared by all keys on that account, and above it the API returns 429. The gateway logs only request metadata (model, token count, time, status); prompts and completions are not stored. Check API quota describes the response fields.

Restore the Claude Code settings

The same script restores the settings file from its backup when the gateway is no longer wanted. Restoring does not delete the key or the package; it returns the Claude Code configuration to the previous state.

bash <(curl -fsSL https://tokenomixai.com/install/claude.sh) --restore
$env:RESTORE="1"; irm https://tokenomixai.com/install/claude.ps1 | iex

Opening a new terminal after the restore keeps the previous environment values out of the next session. Remaining tokens stay on the account and still work in other tools, such as OpenCode or scripts that accept a custom base URL.

Frequently asked questions

Do I need a credit card to install Claude Code and use an API key?

No, if the API key path through a gateway is used. The package is bought on the website, paid with QRIS (Indonesia) or USDT, and the key is sent after payment. There is no account signup and no card verification step.

Does ANTHROPIC_BASE_URL for Claude Code include /v1?

No. The value is https://api.tokenomixai.com on its own, because Claude Code adds /v1/messages itself when it calls the API. Adding /v1 makes the request fail.

Why does Claude Code return 401 after the base URL changes?

Either ANTHROPIC_AUTH_TOKEN does not hold the key that was issued, or the terminal is still running with the old environment. Close it, open a new one, and remove any token from another provider sitting in the same env block.

Is there a 5-hour limit like a Claude subscription?

No. Quota is counted in tokens, and the key keeps working while tokens remain and before it expires. The limit that does apply is 600 requests per minute per account, above which the API returns 429 with Retry-After.

Can the same key be used in OpenCode, Cursor or a script?

Yes. One sk-tkx-... key works with anything that lets you set a base URL, including OpenCode, Cursor, Cline, n8n and OpenAI-compatible SDKs, where the base URL is https://api.tokenomixai.com/v1. The 600 requests per minute are shared across all keys on the account.

More articles