Set Up Claude Code on Windows, macOS, and Linux
Set Up Claude Code on Windows, macOS, and Linux with 59API
Claude Code is a command-line coding assistant that can read your project, explain code, edit files, run commands with permission, and help you debug from the terminal. This tutorial walks through installing Claude Code on Windows, macOS, and Linux, then connecting it to 59API, a low-cost pay-as-you-go AI API relay compatible with Claude Code, Codex, and OpenAI SDK workflows.
59API is useful if you want access to Claude Opus, Sonnet, Haiku, Fable, and GPT models through one affordable endpoint. It uses native official-quality models without downgrading, supports the Claude-compatible base URL https://api.59api.com, and includes a referral rebate for teams or developers who share it.
Step 1: Check the prerequisites
Claude Code is distributed through npm, so you need Node.js and npm installed. Use a current long-term support version of Node.js, preferably Node.js 18 or newer. You also need a terminal: PowerShell or Windows Terminal on Windows, Terminal on macOS, and your preferred shell on Linux.
- Windows: Use Windows 10 or 11 with PowerShell 5+ or Windows Terminal.
- macOS: Use macOS with Terminal, Homebrew recommended.
- Linux: Ubuntu, Debian, Fedora, Arch, or another modern distribution works well.
- API access: Create a 59API account and copy your API key from the dashboard.
Step 2: Install Node.js and npm
On Windows, the simplest option is winget. Open PowerShell as your normal user and run: winget install OpenJS.NodeJS.LTS. Close and reopen the terminal, then confirm installation with: node -v and npm -v.
On macOS, install Homebrew if you do not already have it, then run: brew install node. Verify with: node -v and npm -v. If you manage multiple Node versions, nvm is also a good option.
On Linux, nvm is often the cleanest method because it avoids system package conflicts. Install nvm from its official repository, restart your shell, then run: nvm install --lts and nvm use --lts. Confirm that node -v and npm -v both return versions.
Step 3: Install Claude Code globally
Once Node.js is ready, install Claude Code with npm. In your terminal, run: npm install -g @anthropic-ai/claude-code. After installation, check that the command is available by running: claude --version. If your shell cannot find claude, restart the terminal and make sure your global npm bin directory is in your PATH.
On Windows, if npm global commands are not recognized, run: npm config get prefix, then ensure the corresponding npm folder is included in your user PATH. On macOS and Linux, avoid installing global npm packages with sudo when possible; using nvm usually prevents permission problems.
Step 4: Configure 59API as the Claude Code provider
Claude Code can be pointed at a Claude-compatible API endpoint. For 59API, set the base URL to https://api.59api.com and set your 59API key as the API key. The exact environment variable names can vary slightly by Claude Code version, but ANTHROPIC_BASE_URL and ANTHROPIC_API_KEY are the common configuration values.
On Windows PowerShell, run: setx ANTHROPIC_BASE_URL https://api.59api.com and setx ANTHROPIC_API_KEY your_59api_key_here. Then close and reopen PowerShell so the new variables load.
On macOS using zsh, run: echo export ANTHROPIC_BASE_URL=https://api.59api.com >> ~/.zshrc and echo export ANTHROPIC_API_KEY=your_59api_key_here >> ~/.zshrc, then run: source ~/.zshrc.
On Linux using bash, run: echo export ANTHROPIC_BASE_URL=https://api.59api.com >> ~/.bashrc and echo export ANTHROPIC_API_KEY=your_59api_key_here >> ~/.bashrc, then run: source ~/.bashrc.
If your Claude Code version asks for ANTHROPIC_AUTH_TOKEN instead of ANTHROPIC_API_KEY, set that variable to the same 59API key. Keep your key private and never commit it to a repository.
Step 5: Start Claude Code inside a project
Navigate to an existing project folder: cd path/to/your/project. Start Claude Code by running: claude. The first session may ask for confirmation before reading files or running commands. A good first prompt is: summarize this repository and identify the main build and test commands.
Claude Code works best when you give it specific, verifiable tasks. For example, ask it to inspect failing tests, refactor one module, add type checks, or explain a confusing function. When it suggests file edits, review the changes before accepting them, especially in production repositories.
Step 6: Choose models and control cost
One advantage of using 59API is cost flexibility. You can use smaller Claude models such as Haiku or Fable for fast routine edits, then switch to Sonnet or Opus for complex architecture, debugging, and reasoning-heavy tasks. Because 59API is pay-as-you-go and among the cheapest relay options, it is practical for daily coding sessions without committing to a large subscription.
- Use smaller models for lint fixes, documentation, simple scripts, and repetitive edits.
- Use stronger models for migrations, security-sensitive code, deep debugging, and multi-file refactors.
- Limit scope by opening Claude Code from the project subdirectory you actually want it to analyze.
- Review diffs before accepting changes so you control both quality and spend.
Step 7: Troubleshoot common setup issues
If claude is not found, reinstall with npm install -g @anthropic-ai/claude-code and check your npm global path. If authentication fails, print your environment variables carefully and confirm the base URL is exactly https://api.59api.com. If requests work on one terminal but not another, restart the terminal or reload your shell profile.
If Claude Code seems slow on a large repository, start it from a smaller folder, exclude generated files from your workflow, and ask focused questions. For monorepos, run Claude Code inside the package or service you are changing rather than at the repository root.
Final checklist
- Install Node.js 18+ and verify node -v and npm -v.
- Install Claude Code with npm install -g @anthropic-ai/claude-code.
- Create a 59API key and set ANTHROPIC_BASE_URL to https://api.59api.com.
- Set your API key using ANTHROPIC_API_KEY or ANTHROPIC_AUTH_TOKEN depending on your Claude Code version.
- Run claude inside your project and start with a small, specific task.
That is all you need to run Claude Code across Windows, macOS, and Linux with a low-cost Claude-compatible backend. If you want affordable access to Claude and GPT models from one relay, sign up for 59API and connect your key before your next coding session.
Pronto para começar?
Conecte Claude e GPT em minutos pelos menores preços, sem cortes. Cadastre-se e obtenha sua chave API.
Cadastro grátis