59API

← 返回教程列表

Claude Code Setup: Windows, macOS & Linux Fixes

Claude Code · EN · 2026-10-14

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

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 密钥。

免费注册