Claude Code ANTHROPIC_BASE_URL: Environment Variable Setup
Follow 14 steps and 14 screenshots to set up Terminal, Git, and Node.js LTS on Windows & macOS, fix PowerShell red-text script errors, configure environment variables and settings.json, and verify QCode connectivity with curl.exe.
Need an API key? Sign up →Endpoints & base URLs →
On This Page
- Download and install
- Follow the screenshots: Windows 11, one step at a time
- Open Windows Terminal
- Confirm the tab is PowerShell, not CMD
- Download and install Git for Windows
- Download and install Node.js LTS
- Verify Git and Node.js versions and recognize the PowerShell red-text error
- Check the current PowerShell execution policy
- Allow local scripts for CurrentUser and verify npm
- Open the Windows Environment Variables dialog
- Add the user variable ANTHROPIC_BASE_URL
- Add the user variable ANTHROPIC_AUTH_TOKEN and save
- Open the Claude Code config directory .claude
- Check the env block in settings.json with Notepad
- Open a new Terminal window to verify user environment variables
- Verify network, path, and end-to-end reply with curl.exe
- Verify it works
- Common errors
- FAQ
- What happens when my key expires?
- Do I need to set both user environment variables and settings.json? Which takes precedence?
- Why didn't my environment variable changes take effect?
- Why can't I paste Linux curl commands directly into PowerShell?
- What if the terminal says '$env:ANTHROPIC_BASE_URL' is not recognized as an internal or external command?
- I already ran the one-click setup script — do I still need to do this manually?
- The two core variables and per-tool reference
- macOS / Linux / WSL and other ways to set them
- Other endpoints and regional nodes
- Useful variables when connecting to a gateway
- Related docs
Follow the 14 steps below to install Terminal, Git, and Node.js on Windows 11 or macOS, lift PowerShell's red-text script restriction, save QCode's endpoint URL and API key as permanent environment variables and Claude Code settings, and verify end-to-end connectivity with curl.exe in one shot.
Short answer: In Terminal on Windows 11 or macOS (Windows PowerShell on Windows), verify Git and Node.js LTS and run Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser, add ANTHROPIC_BASE_URL and ANTHROPIC_AUTH_TOKEN in Edit environment variables for your account (and if you also use Claude Code, add them to the env block in %USERPROFILE%\.claude\settings.json), then open a fresh terminal and verify with curl.exe.
| Item | Fill in |
|---|---|
Anthropic endpoint (ANTHROPIC_BASE_URL) |
https://api.qcode.cc/api |
OpenAI-compatible endpoint (OPENAI_BASE_URL) |
https://api.qcode.cc/openai/v1 |
Auth credential (ANTHROPIC_AUTH_TOKEN) |
cr_xxxxxxxx |
| PowerShell execution policy command | Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser |
| Claude Code config file | %USERPROFILE%\.claude\settings.json |
Checked on 2026-11-22 · Windows Terminal 1.25.3131.0 / Git 2.56.1 / Node.js v26.13.1 · Windows 11
Almost every AI coding tool (such as Claude Code, the Anthropic SDK, Codex CLI, and OpenAI-compatible clients) relies on environment variables to decide which service to call and which key to send. If you only want automatic setup for Claude Code, you can also use the one-click setup script; if you want a solid Windows 11 command-line foundation from scratch or prefer to manage environment variables manually, follow the steps below (avoid mixing manual edits with the one-click script so they do not overwrite each other).
On a Mac? Run the same steps in Terminal. The screenshots show Windows PowerShell; on macOS, set a variable with
export NAME="value"instead of$env:NAME = "value", and read%USERPROFILE%\as~/in file paths. The macOS / Linux / WSL and other ways to set them section of this page has the commands that differ.
- Your PC runs Windows 10 / 11 (64-bit) or macOS, and you have permission to install software locally (installing Git and Node.js may trigger a User Account Control prompt)
- You have already signed up on QCode.cc and copied your
cr_API key from the Dashboard. No account yet? Sign up for QCode first, choose a plan on the pricing page, and then create a key in the Dashboard. - Your PC can reach
git-scm.com,nodejs.org(or a regional mirror), andapi.qcode.cc - Set aside about 15 uninterrupted minutes to install the tools in order and reopen Terminal to verify
- If you are on macOS, Linux, or WSL, jump straight to macOS / Linux / WSL and other ways to set them below
Download and install¶
Before starting, here are the official download entry points and Windows build choices for the three core tools (Windows 11 already includes Terminal out of the box):
- Windows Terminal: Pre-installed on Windows 11; on Windows 10 (2004 and later), install from Microsoft Store (auto-updates), download the
.msixbundlefrom GitHub Releases, or runwinget install Microsoft.WindowsTerminal. - Git for Windows: Visit the git-scm.com Windows download page (which redirects to
https://git-scm.com/install/windows), or download from GitHub Releases. Pick64-bit.exeon 64-bit PCs (currentlyGit-2.56.1-64-bit.exe) orarm64.exeon ARM64 PCs; to install from the command line, runwinget install --id Git.Git -e --source winget(a User Account Control prompt will appear). - Node.js LTS: Visit the Node.js download page (the Chinese page shown in the screenshot is nodejs.org/zh-cn/download), select the LTS release (currently
v26.13.1 LTS, bundled with npm11.20.0), and choose the.msiinstaller for beginners (pick x64 or ARM64); to install from the command line, runwinget install OpenJS.NodeJS.LTS.
Network conditions vary slightly by region — pick your region first:
Germany / Japan
- Windows Terminal, Git for Windows, and Node.js have no regional restrictions — install directly via the official links above, Microsoft Store, or
winget. - To install both tools from the command line, run
winget install --id Git.Git -e --source wingetandwinget install OpenJS.NodeJS.LTS, then close and reopen Terminal.
Mainland China
- Node.js: If direct access to
nodejs.orgis slow or drops, download the same LTS.msiinstaller from a domestic mirror such ashttps://nodejs.cn/downloadorhttps://npmmirror.com/mirrors/node/; after installation, you can also switch the npm registry tohttps://registry.npmmirror.comfor faster package installs. - Git for Windows: If GitHub Releases is unstable, download the 64-bit installer (
64-bit.exe) from the Tsinghua mirror athttps://mirrors.tuna.tsinghua.edu.cn/github-release/git-for-windows/git/LatestRelease/. - Windows security prompts: If running
.exeor.msitriggers "Windows protected your PC", click More info → Run anyway; when User Account Control pops up, click Yes. - QCode endpoint: The steps below use the global endpoint
https://api.qcode.cc/apiby default. If it is unstable, users in Asia can switch to the Asia nodehttps://asia.qcode.cc/apiwith the exact same key.
Arab countries
- Use the same channels as Germany / Japan: official installers, Microsoft Store, or
winget. - After installing Git and the Node.js
.msi, make sure to close the old window and reopen Terminal so the updatedPATHtakes effect.
Russia / Iran
- Prefer the official download pages or
wingetfor Git for Windows and Node.js LTS. - If an installer download times out, check that your network connection is stable and retry; after installation, verify both tools in a freshly opened Terminal with
git --versionandnode --version.
Follow the screenshots: Windows 11, one step at a time¶
Each of the 14 steps below does one thing. The orange numbered markers on the screenshots match the circled numbers in the text one to one.
Open Windows Terminal¶
Press the Win key at the bottom left of your keyboard to open the Start menu and type Terminal (in the Chinese Windows 11 screenshot, 终端). Under Best match, find Terminal (终端(应用)) (①), then click Open (打开) on the right (②) or press Enter to launch it. Note that in Chinese Windows 11 Start Search, this app is named 终端 rather than Windows 终端.

Done right you will see: a dark-background Terminal window opens with a tab bar along the top.
Stuck? Searching for Terminal does not find the app
Windows 10 or stripped-down Windows builds may not include Windows Terminal pre-installed. Install it from Microsoft Store or GitHub as shown in Download and install above, or search for Windows PowerShell in the Start menu and open that directly for now.
Confirm the tab is PowerShell, not CMD¶
Once Terminal opens, check two details: the top tab reads Windows PowerShell (①), and the command prompt on the far left starts with PS (②, such as PS C:\Users\<your name>>). If the tab says Command Prompt (命令提示符) and there is no PS prefix, you are in legacy CMD — click the downward arrow next to the tab bar and open a new Windows PowerShell tab.

Done right you will see: the top tab says Windows PowerShell, and the prompt before the cursor starts with PS.
Download and install Git for Windows¶
Open the official Git for Windows download page in your browser (it redirects automatically to /install/windows). Click the blue link at the top to download the latest 64-bit installer (①, currently 2.56.1), double-click the .exe file, and click Next all the way through with the default options; or copy the command under Using winget tool (②) and run it in Terminal for a one-line install:
winget install --id Git.Git -e --source winget

Done right you will see: the setup wizard reaches the Finish screen (or winget reports the installation completed) without exiting on an error.
Stuck? A User Account Control prompt appears, or the official download is slow
Click Yes when User Account Control pops up during Git installation; if you see "Windows protected your PC", click More info → Run anyway. Users in Mainland China experiencing slow downloads from the official site can use the Tsinghua mirror listed under Mainland China in Download and install above to download the 64-bit installer.
Download and install Node.js LTS¶
Open the official Node.js download page (the screenshot shows the Chinese version at nodejs.org/zh-cn/download). First confirm that the version selector at the top is set to an LTS release (①, currently v26.13.1 LTS), then click the green Windows Installer (.msi) (Windows 安装程序(.msi)) button at the bottom left (②). Double-click the .msi and finish with the default options (the installer adds Node.js to PATH by default). Once finished, close your open Terminal window completely and open a fresh one.

Done right you will see: the .msi installer reports completion and closes, and you have opened a brand-new Windows PowerShell window.
Stuck? The page shows a block of fnm commands by default — do I need to copy them?
No. The upper section of the Node.js download page defaults to recommending fnm for version management, but for beginners the green Windows Installer (.msi) button at the bottom left is much simpler. If you prefer command-line installation, you can also run winget install OpenJS.NodeJS.LTS.
Verify Git and Node.js versions and recognize the PowerShell red-text error¶
In the freshly opened Windows PowerShell window, run these three commands one by one:
git --version
node --version
npm --version
Check the output: git --version prints git version 2.56.1.windows.1 (①) and node --version prints v26.13.1 (②), confirming both are installed and on PATH. On a fresh Windows 11 machine, npm --version usually produces a block of red text (③) stating that npm.ps1 cannot be loaded because running scripts is disabled on this system (shown in Chinese in the screenshot as 无法加载文件 …npm.ps1,因为在此系统上禁止运行脚本). Because npm runs through a .ps1 script, Windows' default execution policy blocks it (Claude Code will hit the exact same error later). Nothing went wrong with your installation — the next two steps fix it immediately.

Done right you will see: both git and node print version numbers. If npm --version already prints a version (such as 11.20.0) with no red text, your execution policy is already relaxed and you can skip the next two steps.
Stuck? It says git or node is not recognized
An already-open Terminal window does not automatically reload updated environment variables after installing new software. Close every open Terminal window completely, then launch Terminal again from the Start menu and rerun the commands above.
Check the current PowerShell execution policy¶
In the same Terminal window, enter the command below and press Enter (①) to inspect the execution policy across all scopes:
Get-ExecutionPolicy -List
Look at the CurrentUser row in the table (②). On a fresh Windows 11 system, all five scopes (MachinePolicy, UserPolicy, Process, CurrentUser, LocalMachine) default to Undefined, which resolves to the strictest policy, Restricted (blocking all local .ps1 scripts).

Done right you will see: a two-column, five-row table where the CurrentUser row displays the current policy (by default Undefined).
Allow local scripts for CurrentUser and verify npm¶
Run these three commands in order (no administrator privileges required):
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser
Get-ExecutionPolicy -Scope CurrentUser
npm --version
The first command (①) sets the policy for your user account to RemoteSigned. In Windows 11's built-in Windows PowerShell 5.1, this command takes effect silently with no [Y]/[N] confirmation prompt — it returns straight to the prompt, so do not type an extra Y. Next, run the second command to confirm it prints RemoteSigned (②); then run npm --version and it will print 11.20.0 cleanly (③) with no red text.

Done right you will see: Get-ExecutionPolicy -Scope CurrentUser prints RemoteSigned, and npm --version outputs the version number with no red error text.
Stuck? Typing an extra Y threw red text, or a company PC says the policy is overridden
If you typed Y and pressed Enter out of habit after the first command, PowerShell will report that 'Y' is not recognized as a cmdlet. That does not affect the policy change that already succeeded — just run Get-ExecutionPolicy -Scope CurrentUser to confirm. On a corporate PC where Group Policy locks MachinePolicy or UserPolicy, contact IT, or run Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope Process to allow scripts temporarily in the current window only.
Open the Windows Environment Variables dialog¶
Next, save QCode's endpoint URL and key as permanent user-level environment variables so every future terminal, IDE, and SDK picks them up automatically. Press Win, search for Edit environment variables for your account (in Chinese Windows 11, 编辑帐户的环境变量), and open it — or press Win+R, enter rundll32 sysdm.cpl,EditEnvironmentVariables, and press Enter. This dialog does not require administrator privileges.
In the Environment Variables (环境变量) dialog, the upper half is the User variables (用户变量) section for your account (①). Click New... (新建(N)...) directly below that section (②) to add the first variable.

Done right you will see: the Environment Variables window opens and the New... button under User variables is clickable (the System variables buttons in the lower half being grayed out is normal).
Add the user variable ANTHROPIC_BASE_URL¶
In the New User Variable (新建用户变量) popup, fill in:
- Variable name (
变量名(N):) (①):ANTHROPIC_BASE_URL - Variable value (
变量值(V):) (②):https://api.qcode.cc/api(switch tohttps://asia.qcode.cc/apiif it is unstable)
Double-check that the URL ends at /api with no trailing slash, then click OK (确定) (③).

Done right you will see: the New User Variable popup closes and a new ANTHROPIC_BASE_URL row appears in the User variables list.
Add the user variable ANTHROPIC_AUTH_TOKEN and save¶
Click New... (新建(N)...) under User variables again and add the second variable the same way:
- Variable name (
变量名(N):):ANTHROPIC_AUTH_TOKEN - Variable value (
变量值(V):): paste your QCode API key (starting withcr_, such ascr_xxxxxxxx)
Click OK to return to the main dialog, verify that both ANTHROPIC_AUTH_TOKEN (masked in the screenshot) and ANTHROPIC_BASE_URL appear alphabetically at the top of the list (①), and confirm there is no leftover ANTHROPIC_API_KEY. Finally, be sure to click OK (确定) at the bottom of the dialog (②) so Windows actually saves your changes.

Done right you will see: both variables appear at the top of the User variables list, and the dialog closes cleanly after you click OK at the bottom.
Need an API key?
If you do not have a QCode account yet, Sign up for QCode first. If you prefer to pay by actual usage, buy a Pay-as-you-go Pack first, then create a key in the Dashboard and paste the entire string starting with cr_ into the Variable value field. You can pay by credit/debit card (Visa / Mastercard), Apple Pay / Google Pay, or cryptocurrency — see Payment methods.
Open the Claude Code config directory .claude¶
If you plan to use Claude Code next, you can also write the settings into .claude\settings.json inside your user folder. Press Win+R, type %USERPROFILE%\.claude, and press Enter (if Windows says the path cannot be found, create a new folder named .claude under C:\Users\<your name> first).
In File Explorer, confirm the address bar shows C:\Users\<your name>\.claude (①). Folders starting with . are visible by default on Windows, so you do not need to enable Hidden items under View. Next, create or locate settings.json inside that folder (②).

Done right you will see: File Explorer is inside the .claude folder and contains a file named settings.json (confirm the extension is .json, not .json.txt).
Stuck? The new file became settings.json.txt
In File Explorer's top toolbar, click View → Show → check File name extensions, then remove the trailing .txt. You can also run these two lines in PowerShell to create both the folder and an empty file automatically:
New-Item -ItemType Directory -Path "$env:USERPROFILE\.claude" -Force
New-Item -ItemType File -Path "$env:USERPROFILE\.claude\settings.json" -Force
Check the env block in settings.json with Notepad¶
Right-click settings.json, open it with Notepad (记事本), paste the standard JSON below (replacing cr_xxxxxxxx with your own key), and press Ctrl+S to save:
{
"env": {
"ANTHROPIC_BASE_URL": "https://api.qcode.cc/api",
"ANTHROPIC_AUTH_TOKEN": "cr_xxxxxxxx"
}
}
Verify both fields inside "env": ANTHROPIC_BASE_URL ends at /api with no trailing slash (①), and ANTHROPIC_AUTH_TOKEN contains your full cr_ key (②, masked in the screenshot). Also make sure ANTHROPIC_API_KEY is not in this file — keep ANTHROPIC_AUTH_TOKEN as the only credential.

Done right you will see: the JSON uses straight double quotes, matching braces, and no trailing commas or comments, and the unsaved indicator in the title bar disappears after saving.
Stuck? The file already has other settings in it
If settings.json already contains other keys, do not overwrite the whole file — simply add the "env": { ... } block alongside the existing top-level keys inside { ... }, separated by commas. Remember settings.json is strict JSON and does not allow // comments.
Open a new Terminal window to verify user environment variables¶
Already-open Terminal windows on Windows do not automatically pick up newly saved variables. Close the old window, open a fresh Terminal from the Start menu, and run these three commands:
echo $env:ANTHROPIC_BASE_URL
$env:ANTHROPIC_AUTH_TOKEN.Length
[string]::IsNullOrEmpty($env:ANTHROPIC_API_KEY)
Check all three lines of output: ANTHROPIC_BASE_URL echoes https://api.qcode.cc/api verbatim (①); $env:ANTHROPIC_AUTH_TOKEN.Length prints the character length of your key (for example 67, confirming it is non-empty without printing the secret in plain text, ②); and the last command returns True (③), confirming no conflicting ANTHROPIC_API_KEY is left in your environment.

Done right you will see: Terminal outputs https://api.qcode.cc/api, a number greater than 0, and True, in that order.
Stuck? The first line is blank, or the third line returns False
A blank first line usually means you forgot to close and reopen Terminal, or forgot to click OK at the bottom of the Environment Variables dialog earlier. If the third line returns False, you have an old ANTHROPIC_API_KEY set — go back to the Environment Variables dialog, delete it, and reopen Terminal to re-check.
Verify network, path, and end-to-end reply with curl.exe¶
Finally, run a connectivity and end-to-end reply test using Windows' built-in curl.exe. In the same Windows PowerShell window, run these two commands in order (in PowerShell 5.1, you must use curl.exe and -o NUL rather than curl and /dev/null):
curl.exe -s -o NUL -w "%{http_code}\n" -H "Authorization: Bearer $env:ANTHROPIC_AUTH_TOKEN" https://api.qcode.cc/v1/models
$body = '{"model":"claude-opus-5-5","max_tokens":32,"messages":[{"role":"user","content":"Reply with exactly: OK"}]}'
$body | curl.exe -s -X POST "$env:ANTHROPIC_BASE_URL/v1/messages" -H "x-api-key: $env:ANTHROPIC_AUTH_TOKEN" -H "anthropic-version: 2023-06-01" -H "content-type: application/json" --data-binary "@-"
Check both outputs: the first request hits /v1/models with your Bearer token and prints status code 200 (①); the second pipes the JSON body to $env:ANTHROPIC_BASE_URL/v1/messages and returns a JSON response containing "text":"OK" (②). Seeing both confirms your network, endpoint path, and key are all working.

Done right you will see: the first command prints only 200, and the second returns full JSON containing "text":"OK", with no 401, 404, or path error.
Stuck? It returned 401, 404, or a wall of HTML
401 means the key is invalid or missing characters — double-check the cr_ prefix and trim any leading/trailing spaces. 404 usually means an extra trailing / on ANTHROPIC_BASE_URL or a typo in the path. A wall of webpage HTML means no key was attached ($env:ANTHROPIC_AUTH_TOKEN is empty) — go back one step and make sure the variables are loaded.
Verify it works¶
When all five checks below match, your Windows 11 development environment and QCode connection are ready:
git --version,node --version, andnpm --versionall print version numbers with no red errors;Get-ExecutionPolicy -Scope CurrentUseroutputsRemoteSigned;- In a freshly opened Terminal,
echo $env:ANTHROPIC_BASE_URLprintshttps://api.qcode.cc/api(orhttps://asia.qcode.cc/api),$env:ANTHROPIC_AUTH_TOKEN.Lengthis greater than 0, and[string]::IsNullOrEmpty($env:ANTHROPIC_API_KEY)returnsTrue; curl.exeagainst/v1/modelsreturns200, and the end-to-end request to$env:ANTHROPIC_BASE_URL/v1/messagesreturns JSON containing"text":"OK";- Opening probe.qcode.cc and entering the same
cr_key shows the test request you just sent.
All done¶
Your Windows 11 command-line environment, environment variables, and QCode connectivity are set up and verified. Next you can:
- Install Claude Code (Installation Guide)
- One-Click Setup Script
- Endpoints and API Formats
- Chinese Models Setup
- Next: compare plans on the pricing page
- Return to the Dashboard to check usage and balance
Common errors¶
| Error message | Why | What to do |
|---|---|---|
npm : File C:\Program Files\nodejs\npm.ps1 cannot be loaded because running scripts is disabled on this system. |
Windows 11 defaults PowerShell's execution policy to Undefined (effectively Restricted), blocking local scripts such as npm.ps1 and claude.ps1 (shown in Chinese Windows as 无法加载文件 … 禁止运行脚本) |
Run Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser in PowerShell (no admin rights needed), then verify Get-ExecutionPolicy -Scope CurrentUser returns RemoteSigned |
Y : The term 'Y' is not recognized as the name of a cmdlet, function, script file, or operable program. |
Changing execution policy with -Scope CurrentUser in Windows PowerShell 5.1 succeeds silently with no confirmation prompt, so typing an extra Y runs it as a command |
The policy is already active — ignore this red error and verify with Get-ExecutionPolicy -Scope CurrentUser and npm --version |
Warning: Failed to open the file /dev/null: The system cannot find the path specified |
Copying a Linux/macOS curl -o /dev/null command directly into Windows PowerShell fails because Windows has no /dev/null (and curl is an alias for Invoke-WebRequest) |
Use curl.exe and replace -o /dev/null with -o NUL; when testing QCode, pipe the JSON via --data-binary "@-" as shown above |
{"error":{"message":"Invalid or missing API key","type":"invalid_request_error","code":"invalid_api_key"}} |
Calling https://api.qcode.cc/v1/models without a key (or with an empty $env:ANTHROPIC_AUTH_TOKEN), or with an invalid key, returns HTTP 401 with this JSON error |
Confirm $env:ANTHROPIC_AUTH_TOKEN.Length is greater than 0 in a new Terminal, pass -H "Authorization: Bearer $env:ANTHROPIC_AUTH_TOKEN" to curl.exe, and run the /v1/messages end-to-end check; if the message says the key is disabled or has expired, switch to the currently active API key in your console |
FAQ¶
What happens when my key expires?¶
Two cases:
- A personal plan key cannot be renewed when it expires — you must start a new plan and switch to a new key;
- A pay-as-you-go pack key automatically resumes working when you buy another pack after it expires.
After switching to a new key, return to the Environment Variables dialog to update ANTHROPIC_AUTH_TOKEN (and if you also configured %USERPROFILE%\.claude\settings.json, update that too and reopen Terminal).
Do I need to set both user environment variables and settings.json? Which takes precedence?¶
- Windows user environment variables apply globally to all CLI tools, IDEs, and SDKs (Claude Code, Anthropic SDK, Python/Node scripts, etc.);
- The
envblock in%USERPROFILE%\.claude\settings.jsonapplies only to Claude Code.
If both define the same variable, the environment variable inherited by the process at startup takes precedence over the config file. Keep both in sync — or maintain only the one you actually use — so you do not update a key in one place while an older key stays in the other and causes 401 errors.
Why didn't my environment variable changes take effect?¶
Already-open Terminal, VS Code, or editor windows on Windows do not reload newly saved user variables automatically. Make sure you clicked OK at the bottom of the Environment Variables dialog, then close your terminal or editor completely and reopen it (do not just minimize it). If edits to settings.json do not apply, check for missing commas, curly quotes, or comments.
Why can't I paste Linux curl commands directly into PowerShell?¶
Windows PowerShell 5.1 differs in three ways: first, curl is an alias for Invoke-WebRequest, so you must explicitly invoke curl.exe; second, Windows has no /dev/null, so write -o NUL; third, passing -d '{"model":...}' directly strips double quotes and breaks JSON parsing — assigning the payload to $body and piping it into --data-binary "@-" works reliably.
What if the terminal says '$env:ANTHROPIC_BASE_URL' is not recognized as an internal or external command?¶
You are in legacy Command Prompt (CMD) instead of PowerShell. Check the tab title and prompt prefix to make sure it starts with PS, then switch to a Windows PowerShell tab and run the command again.
I already ran the one-click setup script — do I still need to do this manually?¶
No need to redo it. The one-click setup script has already written the required configuration for Claude Code; if you manually edit user variables or settings.json later, whichever value you saved last takes effect. For quick automated setup, see One-Click Setup Script.
The two core variables and per-tool reference¶
Connecting to Claude-family models (Claude Code and the official Anthropic Python / TypeScript SDKs) requires only two core environment variables:
ANTHROPIC_BASE_URL: The endpoint URL ending at/api(https://api.qcode.cc/api). The SDK appends/v1/messagesautomatically. Do not include a trailing slash —https://api.qcode.cc/api/turns into//v1/messagesand returns404.ANTHROPIC_AUTH_TOKEN: Your QCode.cc key, starting withcr_, created in the QCode.cc Dashboard.
About
ANTHROPIC_AUTH_TOKEN: By QCode convention, the relay key goes intoANTHROPIC_AUTH_TOKEN(rather thanANTHROPIC_API_KEY, which the official Anthropic API uses), and Claude Code sends it viaAuthorization: Bearer. When configuring Claude Code, removeANTHROPIC_API_KEYand keep onlyANTHROPIC_AUTH_TOKEN. If a third-party tool only recognizesANTHROPIC_API_KEY, entering the samecr_key there works too.
Different tools read different variable names and URL prefixes — match yours below:
| Tool | Environment variables | Value |
|---|---|---|
| Claude Code | ANTHROPIC_BASE_URLANTHROPIC_AUTH_TOKEN |
https://api.qcode.cc/apicr_xxxxxxxx |
| Anthropic SDK (Python / JS) | ANTHROPIC_BASE_URLANTHROPIC_AUTH_TOKEN |
https://api.qcode.cc/apicr_xxxxxxxx |
| Codex CLI | base_url in ~/.codex config |
https://api.qcode.cc/openai |
| OpenAI-compatible tools | OPENAI_BASE_URLOPENAI_API_KEY |
https://api.qcode.cc/openai/v1cr_xxxxxxxx |
| Gemini / Antigravity (currently unavailable) | base URL | https://api.qcode.cc/gemini |
A few notes:
- Codex CLI does not read
OPENAI_BASE_URL; it readsbase_urlfrom~/.codex. Because it uses the OpenAI Responses protocol and appends paths itself, end the URL at/openaiwith no/v1. See Endpoints and API Formats for details. - OpenAI-compatible tools (official OpenAI SDK, LangChain, generic clients) read
OPENAI_BASE_URLandOPENAI_API_KEY, ending at/openai/v1. - Gemini / Antigravity (QCode does not offer Gemini for now; protocol reference only): ends at
/gemini, and the SDK appends/v1beta/. - One key across protocols: Your
cr_key is protocol-agnostic —/apispeaks Anthropic,/openai/v1speaks OpenAI. Switching tools only means changing the URL, never the key.
Available models¶
Once your endpoint is set, choose a model ID matching your tool's protocol (see Endpoints and API Formats for details, and qcode.cc/models for the live model list):
- Claude family (5-series daily default):
claude-opus-5-5(1M, recommended flagship),claude-sonnet-5-5(1M, balanced),claude-fable-5-2/claude-fable-5-1/claude-fable-5(1M, top tier),claude-sonnet-4-6/claude-opus-4-8/claude-opus-4-7(previous generation, still available),claude-haiku-5-5(1M, fastest) - GPT family:
gpt-6.2-sol(recommended),gpt-6.2-astra, andgpt-6-sol - Gemini family: Not currently offered by QCode — use Claude, GPT, or Chinese models
- Chinese models (GLM / Kimi / DeepSeek / Qwen):
qwen3.8-max,deepseek-v4.1-flash,deepseek-v4-pro,kimi-k3.1-pro,kimi-k3,glm-5.3, and more — see Chinese Models Setup - Images:
gpt-image-2(endpointhttps://api.qcode.cc/qcode-img/v1)
Claude Code context length: Claude Code gives Claude 5.5 models and Fable 5.2 a 1M window by default; to pin a 200K window, set
CLAUDE_CODE_DISABLE_1M_CONTEXT=1.
macOS / Linux / WSL and other ways to set them¶
If you use macOS, Linux, or Windows WSL — or want to isolate keys per project — pick the configuration scope that fits your workflow:
- Shell rc file (persistent, global): Add to
~/.zshrc(macOS / zsh) or~/.bashrc(Linux / WSL / bash) so every new terminal loads them automatically:
echo 'export ANTHROPIC_BASE_URL="https://api.qcode.cc/api"' >> ~/.zshrc
echo 'export ANTHROPIC_AUTH_TOKEN="cr_xxxxxxxx"' >> ~/.zshrc
source ~/.zshrc
For bash, replace ~/.zshrc with ~/.bashrc.
- Project
.envfile (persistent, per project): Place a.envfile in the project root so it only affects that project — handy when different projects use different keys:
ANTHROPIC_BASE_URL=https://api.qcode.cc/api
ANTHROPIC_AUTH_TOKEN=cr_xxxxxxxx
.envcontains your key — always add it to.gitignoreand never commit it to a repository.
- Tool-specific config files (per tool): Such as Claude Code's
~/.claude/settings.json(%USERPROFILE%\.claude\settings.jsonon Windows), Codex CLI's~/.codex, or an editor plugin's settings panel. These apply only to that tool.
Persistent vs. temporary: All three options above are persistent. If you only want to test in the current terminal session (cleared as soon as you close the window), run:
# Temporary setup on macOS / Linux / WSL
export ANTHROPIC_BASE_URL="https://api.qcode.cc/api"
export ANTHROPIC_AUTH_TOKEN="cr_xxxxxxxx"
# Temporary setup in Windows PowerShell
$env:ANTHROPIC_BASE_URL = "https://api.qcode.cc/api"
$env:ANTHROPIC_AUTH_TOKEN = "cr_xxxxxxxx"
Precedence note: System / shell environment variables inherited at process startup take precedence over config files. Remember to run
sourceor open a new terminal after editing shell rc files; when the same variable is set in multiple places, whichever value the process actually inherits wins.
On macOS / Linux / WSL, verify with bash curl (confirm $ANTHROPIC_AUTH_TOKEN is non-empty, then check the status code and end-to-end reply):
echo "$ANTHROPIC_BASE_URL"
curl -s -o /dev/null -w '%{http_code}\n' \
-H "Authorization: Bearer $ANTHROPIC_AUTH_TOKEN" \
https://api.qcode.cc/v1/models
curl -X POST "$ANTHROPIC_BASE_URL/v1/messages" \
-H "x-api-key: $ANTHROPIC_AUTH_TOKEN" \
-H "anthropic-version: 2023-06-01" \
-H "content-type: application/json" \
-d '{"model":"claude-opus-5-5","max_tokens":64,"messages":[{"role":"user","content":"ping"}]}'
Reading the status codes: A 200 with a valid key plus a normal JSON reply from the second command means your network, endpoint, and key are all ready. 401 means the key is invalid or not passed properly (check the full cr_ prefix). 404 usually means a wrong path prefix or an extra trailing /.
Other endpoints and regional nodes¶
QCode offers three ingress domains with identical capabilities; your single cr_ key works across all of them:
| Node | Anthropic-compatible (Claude Code / SDK) | OpenAI-compatible | Codex CLI |
|---|---|---|---|
| Global (default) | https://api.qcode.cc/api |
https://api.qcode.cc/openai/v1 |
https://api.qcode.cc/openai |
| Asia | https://asia.qcode.cc/api |
https://asia.qcode.cc/openai/v1 |
https://asia.qcode.cc/openai |
| North America / Europe | https://us.qcode.cc/api |
https://us.qcode.cc/openai/v1 |
https://us.qcode.cc/openai |
By default, use https://api.qcode.cc; if it is unstable, switch to https://asia.qcode.cc (Asia) or https://us.qcode.cc (North America / Europe). See Endpoints and API Formats for details.
Want to inspect the status and latency of every request? Requests across all ingress domains report to probe.qcode.cc — enter your
cr_key to view them.
Useful variables when connecting to a gateway¶
When Claude Code connects through a third-party gateway (including QCode), the official environment variables below are helpful for default model selection and troubleshooting. Definitions follow the official environment variables reference and the LLM gateway connection guide:
| Variable | When to use it |
|---|---|
ANTHROPIC_DEFAULT_MODEL |
Sets the default model for new sessions (since 2.1.236). Unlike ANTHROPIC_MODEL, an in-session /model choice overrides it and persists across restarts, whereas ANTHROPIC_MODEL is forced on every launch |
CLAUDE_CODE_ENABLE_GATEWAY_MODEL_DISCOVERY=1 |
Lets the /model picker query the gateway's model list (off by default so shared-key gateways do not expose models you lack access to). Against QCode, only Claude-family IDs appear; Chinese models will not appear, so keep using ANTHROPIC_MODEL or ANTHROPIC_DEFAULT_MODEL for them |
CLAUDE_CODE_DISABLE_EXPERIMENTAL_BETAS=1 |
Strips the anthropic-beta header and beta tool fields. Enable this if the gateway returns a 400 error like Unexpected value(s) … anthropic-beta |
CLAUDE_CODE_AUTO_MODE_SERVER=0 |
Stops auto mode from requesting server-side review and runs Claude Code's local classifier requests directly (QCode does not return server-side review results). Once set, the incompatibility notice disappears and the first action requiring review is no longer paused. If QCode's one-click setup script already added it, you do not need to add it manually. Officially marked temporary and may be removed in a future release — see Feature Availability |
CLAUDE_CODE_DISABLE_ARTIFACT=1 |
Disables the Artifact tool (once set, it cannot be re-enabled in the settings UI). If you are stuck on Claude Code 2.1.265–2.1.267, hit gateway 400 rejections on tool schemas, and cannot upgrade to ≥2.1.268 yet, use this as a temporary workaround |
CLAUDE_CODE_ATTRIBUTION_HEADER=0 |
Removes the attribution block (client version and prompt fingerprint) from the top of the system prompt. Read the official documentation before deciding whether to disable it |
Related docs¶
- Installation Guide — Install and launch Claude Code
- One-Click Setup Script — Configure Claude Code with a single command
- Endpoints and API Formats — Protocol URLs and ingress domains
- How to Choose a Plan — Pick the right QCode plan and get a
cr_key - Chinese Models Setup — Chinese model IDs available on the OpenAI-compatible endpoint
- Feature Availability — Claude Code feature support and gateway variable reference
Get started with QCode
One API key for Claude Code, Codex and more — billed per token, per-model prices on qcode.cc/models