Install Claude Code on Mac With One Terminal Command
To install Claude Code on Mac through Terminal, run two steps in order: install the Claude Code CLI, then run the TokenomixAI installer so the base URL and auth token land in ~/.claude/settings.json. Open a new terminal window, start Claude Code, and your first session is ready.
Installing Claude Code on Mac finishes in two steps: install the CLI, run the TokenomixAI installer from Terminal so ANTHROPIC_BASE_URL and ANTHROPIC_AUTH_TOKEN are filled in for you, then verify in a new terminal window.
What you need before you install Claude Code on Mac
Before you touch the installer, make sure two things exist: the Claude Code CLI is installed on macOS, and you have one TokenomixAI API key. The CLI comes from the official Claude Code site at claude.ai or docs.anthropic.com, not from TokenomixAI.
You get the API key after buying a package on tokenomixai.com. No account or credit card is needed, the key is sent after payment via QRIS or USDT. The key format is sk-tkx-... and it works across the text and code models on the list.
- macOS with the built-in Terminal or iTerm2
- Claude Code CLI installed and callable from Terminal
- A TokenomixAI API key in the sk-tkx-... format
- A stable connection while the installer writes settings
If Terminal answers that the command was not found, the CLI is not installed yet or is not on your PATH. Finish the CLI install first, then continue. The install commands live in the docs.
Install Claude Code on Mac with one command
The TokenomixAI installer for Claude Code runs on macOS and Linux with a single command. Run it in Terminal, then type your API key when the script asks for it. The key is typed at the prompt and never put into a URL.
bash <(curl -fsSL https://tokenomixai.com/install/claude.sh)All the installer writes is two lines in the env block of ~/.claude/settings.json: ANTHROPIC_BASE_URL=https://api.tokenomixai.com and ANTHROPIC_AUTH_TOKEN holding your key. Other settings you already have are kept, and the old file is backed up first.
Watch one detail that people get wrong: the base URL for Claude Code has no /v1. Claude Code appends the /v1/messages path itself when it calls the API, so adding /v1 to ANTHROPIC_BASE_URL sends requests to the wrong address.
| Tool | Base URL to use |
|---|---|
| Claude Code | https://api.tokenomixai.com |
| OpenCode, OpenAI-compatible SDKs, n8n, curl | https://api.tokenomixai.com/v1 |
On Windows the PowerShell installer does the same job and writes to %USERPROFILE%\.claude\settings.json.
irm https://tokenomixai.com/install/claude.ps1 | iexCheck that Claude Code runs in a new terminal
Environment variables are read when a process starts, so a terminal window that was open before the install does not carry the new settings. Close that window, open a fresh one, and start Claude Code from there.
- Close every old Terminal window
- Open a new Terminal and change into your project folder
- Start Claude Code and ask one short question
- Confirm the answer arrives without an authentication error
- Open
~/.claude/settings.jsonand check the env block is filled
If the first reply comes back normally, the install is done. You can move straight into daily work such as reading files, editing and committing. The full walkthrough from first session to first commit is in How to Use Claude Code.
One limit is worth knowing up front: quota is counted in tokens, not time windows, so there is no 5 hour lockout. What does apply is a rate limit of 600 requests per minute per account, shared by all the keys on that account. Above that number the API returns 429 with a Retry-After header.
Claude Code errors after install: what to check
A 401 almost always means the token was not read. Check that ANTHROPIC_AUTH_TOKEN really sits in the env block, that the key was copied whole with no trailing space, and that the terminal you are typing in was reopened after the installer finished.
- Old terminal still holding the previous environment, reopen it
- Wrong
ANTHROPIC_BASE_URLvalue, for example with/v1appended - API key truncated on copy, or a stray space pasted with it
- Settings file overwritten by another tool after the installer ran
If the error says the key is invalid, compare the shape of your key against a typical sk-tkx-... value and make sure nothing got cut off. If requests run but come back as 429, that is the rate limit and not a key problem, so wait for the interval in Retry-After. The common causes are collected in 401 API Key Error.
For the full picture on these two variables, read Anthropic Base URL and Auth Token.
Restore your Claude Code settings
The installer saves a backup before changing the file, so you can go back to the original configuration at any time. Run the restore command in Terminal and the installer puts ~/.claude/settings.json back the way it was before the change.
bash <(curl -fsSL https://tokenomixai.com/install/claude.sh) --restoreOn Windows, set the RESTORE variable before calling the same script. After a restore, open a new terminal again so the environment picks up the old settings.
$env:RESTORE="1"; irm https://tokenomixai.com/install/claude.ps1 | iexCheck remaining quota after Claude Code is active
A Claude Code session spends tokens from the same quota as your key. To see what is left, call the quota endpoint with that key. The response carries status, remainingTokens, maxTokens, usagePercent, expiresAt, and low, which is true when 10 percent or less remains.
curl https://api.tokenomixai.com/v1/quota -H "Authorization: Bearer sk-tkx-..."If status reads exhausted, the key stops serving requests until you top up. Tokens from a top-up are added to the existing quota and the key stays the same, so nothing in Claude Code needs reconfiguring. How to read each field is covered in Check API Quota.
Frequently asked questions
Does the Claude Code installer need an API key before it runs?
Yes. The script asks for the key while it runs, so have a key in the sk-tkx-... format ready first. You type the key at the prompt, and it is never placed in a URL or on the command line.
Why does Claude Code still fail after the installer finished?
The most common cause is a terminal that was not reopened, so the old environment is still in use. Another cause is ANTHROPIC_BASE_URL written with an extra /v1, even though Claude Code adds that path itself.
Will my existing Claude Code settings be lost?
No. The installer only adds ANTHROPIC_BASE_URL and ANTHROPIC_AUTH_TOKEN to the env block, and your other settings are kept. The old file is also backed up before it is changed.
Is there a 5 hour usage window like a subscription?
There is no 5 hour time window. Quota is counted in tokens and keeps working while tokens remain and the key has not expired. What does apply is a rate limit of 600 requests per minute per account, and above that the API returns 429.
Do I need to reinstall Claude Code on Mac after a top up?
No. The key stays the same after a top up, and the new tokens are added to the quota you already have. Settings in ~/.claude/settings.json do not change, so you can keep working.