Claude Code Setup: Windows, macOS & Linux Fixes
Set up Claude Code without the usual roadblocks
Claude Code runs in your terminal, reads your project and helps with development tasks. Getting it working requires three things: a supported installation, valid authentication and access to a compatible model. This guide covers Windows, macOS and Linux, then explains how to connect 59API and diagnose common failures.
1. Install Claude Code on your operating system
macOS: Open Terminal and run: curl -fsSL https://claude.ai/install.sh | bash
Linux: Run the same command in your shell: curl -fsSL https://claude.ai/install.sh | bash
These are native installation commands, so a separate Node.js installation is unnecessary. Use the official installer URL, and inspect downloaded scripts before executing them if your security policy requires it.
Windows: Install Git for Windows, which supplies the Bash environment Claude Code needs. Then open PowerShell and run: irm https://claude.ai/install.ps1 | iex
If Claude Code cannot locate Git Bash, set its path in PowerShell: $env:CLAUDE_CODE_GIT_BASH_PATH = "C:\Program Files\Git\bin\bash.exe". Adjust that path if Git is installed elsewhere.
Using WSL instead? Open your Linux distribution inside WSL and follow the Linux instructions. Keep installation, credentials and project commands in that environment rather than mixing Windows and WSL installations.
After installation, reopen your terminal and run claude --version. Then run claude doctor to check installation health.
2. Connect Claude Code to 59API
59API offers low-cost, pay-as-you-go access to Claude and GPT models, with compatibility for Claude Code, Codex and OpenAI SDKs. It describes its models as native, official-quality offerings without downgrades. Its referral rebate is another potential saving, although current prices and rebate terms should be checked before budgeting.
For Claude Code, use 59API's Claude-compatible configuration, not an OpenAI SDK configuration. The service base URL is https://api.59api.com. Check its dashboard documentation for the required authentication header and supported model IDs.
macOS or Linux, API-key authentication: Run: export ANTHROPIC_BASE_URL="https://api.59api.com"; export ANTHROPIC_API_KEY="YOUR_59API_KEY"
Windows PowerShell, API-key authentication: Run: $env:ANTHROPIC_BASE_URL = "https://api.59api.com"; $env:ANTHROPIC_API_KEY = "YOUR_59API_KEY"
If 59API's instructions specify bearer authentication instead, use ANTHROPIC_AUTH_TOKEN rather than ANTHROPIC_API_KEY. Avoid defining both while troubleshooting. Do not append /v1/messages to the base URL; the client constructs API request paths.
These settings apply to the current terminal session. Test them before making them persistent. Never commit API keys to your repository or include them in screenshots.
3. Test a small request first
Navigate to your project with cd your-project, then run claude. Use /status to inspect the session and /model to check model selection. If the relay requires an explicit model, use its documented model ID rather than guessing an alias.
Start with: “Explain this repository's structure without changing files.” Confirm the request appears in your 59API usage dashboard. Commit or back up important work before authorizing edits or shell commands.
Troubleshooting: common errors and practical fixes
- “claude” is not recognized: Reopen the terminal. Check that the installer's executable directory is on PATH. On macOS and Linux, this is commonly ~/.local/bin; use the location reported by your installer.
- 401 or authentication failure: Check the key, authentication method and account balance. Remove conflicting credentials from the session and restart Claude Code from the configured terminal.
- 404 or model not found: Verify the base URL and model ID. A relay's OpenAI compatibility does not mean Claude Code uses OpenAI request formats.
- 429 or rate-limit errors: Reduce parallel sessions and check quotas. Repeated immediate retries can prolong throttling.
- Connection failures: Check DNS, proxy settings, firewall rules and HTTPS access to the relay. Do not disable certificate verification as a workaround.
Frequently asked questions
Does a Claude subscription cover relay usage? No. Requests authenticated with a relay key are billed through that relay, separately from a Claude subscription.
How can I keep costs predictable? Start with small tasks, monitor usage and choose a lower-priced supported model when appropriate. Long conversations and large tool outputs can increase token consumption.
Is a relay suitable for private code? Review its data-handling policy and your organization's rules first. If the setup and pricing fit your needs, sign up for 59API and test a small request before scaling up.
शुरू करने के लिए तैयार?
कुछ ही मिनटों में Claude और GPT जोड़ें, सबसे कम कीमत पर। साइन अप करें और API key पाएं।
मुफ़्त साइन अप