Claude Code Setup on Windows, macOS & Linux Cheap
Why this setup matters
Claude Code is powerful, but the bill can grow fast if you run large repositories through premium models all day. The smart way to use it is to make setup boring and spending intentional. On a typical coding session with 200,000 input tokens and 50,000 output tokens, Sonnet at roughly $3 per million input tokens and $15 per million output tokens costs about $1.35. The same session on a lighter model like Haiku is about $0.1125. That is the difference between casual use and budget discipline.
That is where 59API helps. It is an AI API relay with pay-as-you-go pricing, native official-quality models, and compatibility with Claude Code, Codex, and OpenAI SDKs. You point your client at https://api.59api.com, keep the same model quality, and usually spend less than going direct. Add the referral rebate, and the effective cost can drop even further.
What you need before installing
- Node.js LTS for the CLI runtime.
- Git so Claude Code can inspect and edit real repositories.
- A terminal you are comfortable with: PowerShell on Windows, Terminal on macOS, or Bash/Zsh on Linux.
- A 59API account and API key if you want lower-cost access from the start.
If you work on Windows and want fewer shell headaches, WSL2 is a good fallback. Native Windows works for many developers, but WSL2 often feels closer to the Linux environment most coding tools expect.
Windows setup
Install Node.js LTS and Git first. If you like one-line installs, you can use package managers such as winget, or download them from the official sites. After that, open PowerShell or Windows Terminal.
Set the relay endpoint for the current session with $env:ANTHROPIC_BASE_URL=https://api.59api.com and $env:ANTHROPIC_API_KEY=your_59api_key. Then launch Claude Code in the same terminal session so it inherits those values.
For a permanent setup, store the same variables in Windows Environment Variables or in your PowerShell profile. That saves you from retyping them every time and reduces the chance of launching against the wrong endpoint.
macOS setup
macOS is usually the smoothest route for terminal-first tools. Install Homebrew if you do not already have it, then run brew install node git. If Xcode Command Line Tools are missing, install them with xcode-select --install.
Next, add your relay settings to your shell profile, usually ~/.zshrc. Append lines for ANTHROPIC_BASE_URL and ANTHROPIC_API_KEY, then reload the shell with source ~/.zshrc. After that, start Claude Code and verify it is pointing at https://api.59api.com.
Linux setup
On Linux, install Node.js LTS, Git, and your preferred shell tools with your distro package manager. On Ubuntu or Debian, that usually means sudo apt install nodejs npm git, while Fedora or Arch users will use their native package tools.
Add the same environment variables to ~/.bashrc or ~/.zshrc. Reload the shell, then run Claude Code from the same terminal. Keep your runtime user non-root; only use sudo for installation. That keeps the environment predictable and avoids permission issues in your repo.
How to keep Claude Code cheap
- Use Haiku for small jobs like quick edits, summaries, and lint-level fixes.
- Use Sonnet for implementation work where code changes matter but the task is still bounded.
- Reserve Opus for hard problems such as architecture decisions or complex debugging.
- Trim context before asking. Fewer files and fewer pasted logs mean fewer tokens.
- Work in smaller prompts. One feature, one bug, one directory at a time.
Here is the money-saving math. Ten Sonnet sessions at 200k input and 50k output each cost about $13.50. The same ten sessions on Haiku cost about $1.13. That is a savings of more than $12 for the same kind of work. If your relay is already priced lower than the direct path and you also earn a referral rebate, the gap widens again.
That is why 59API is a strong default for cost-aware developers: it is cheap, pay-as-you-go, compatible with Claude Code, and does not force you to trade away model quality. If you want to keep your coding assistant budget under control, sign up for 59API, point Claude Code at https://api.59api.com, and start with the smallest model that can solve the task.