Skip to content

Claude Code + modelfold.ai Integration Guide ​

With a simple environment variable setup, you can route your local Claude Code through modelfold.ai's proxy and use your modelfold.ai account credits. Installation time depends on your network.


Prerequisites ​

Have a ModelFold API key and available credits. Set only ANTHROPIC_AUTH_TOKEN to the raw key, without Bearer . Avoid setting both credential variables.

VariableValue
ANTHROPIC_BASE_URLhttps://modelfold.ai/anthropic
ANTHROPIC_AUTH_TOKENYour raw ModelFold API key

Step 1: Install Claude Code ​

Mac ​

Open Terminal and paste:

bash
curl -fsSL https://claude.ai/install.sh | bash

The native installer does not require Node.js. In some regions the installation URL redirects to app-unavailable-in-region, followed by syntax error near unexpected token '<': the response is HTML, not an installation script. Use a proxy that can reach the official downloads and retry. Replace the port with your own proxy port:

bash
export HTTP_PROXY="http://127.0.0.1:7897"
export HTTPS_PROXY="http://127.0.0.1:7897"
curl -fsSL https://claude.ai/install.sh | bash

If installation succeeds but claude is not found:

bash
echo 'export PATH="$HOME/.local/bin:$PATH"' >> ~/.zshrc
source ~/.zshrc
claude --version

Windows ​

Open PowerShell from the Start menu and paste:

powershell
irm https://claude.ai/install.ps1 | iex

After installation, run claude --version. If you see a version number, the installation succeeded.

⚠️ If the claude command is not found, check that Claude Code was added to your PATH.

⚠️ After installing, do not log in with an Anthropic account. You will connect using your modelfold.ai credentials in the next step.


Step 2: Set Your Credentials (Choose One Method) ​

Configure once — every terminal session will automatically route through modelfold.ai.

Mac ​

Open Terminal and paste the following (replace the key with your own):

bash
echo 'export ANTHROPIC_BASE_URL="https://modelfold.ai/anthropic"' >> ~/.zshrc
echo 'export ANTHROPIC_AUTH_TOKEN="your_MODELFOLD_API_Key"' >> ~/.zshrc
source ~/.zshrc

Windows ​

Open PowerShell and paste the following (replace the key with your own):

powershell
[Environment]::SetEnvironmentVariable("ANTHROPIC_BASE_URL", "https://modelfold.ai/anthropic", "User")
[Environment]::SetEnvironmentVariable("ANTHROPIC_AUTH_TOKEN", "your_MODELFOLD_API_Key", "User")

On Mac, source ~/.zshrc applies the variables to the current shell. On Windows, user environment variables apply to new processes; reopen the terminal and restart your editor if using an integrated terminal.


Method B: Claude Code Settings File ​

Takes effect only when running claude. Does not affect other programs on your system — a cleaner option if you prefer isolation.

Open the file below (create it if it doesn't exist), add the content, and replace the key:

  • Mac: ~/.claude/settings.json
  • Windows: C:\Users&lt;your-username>.claude\settings.json

ANTHROPIC_AUTH_TOKEN (no Bearer prefix)

json
{
  "env": {
    "ANTHROPIC_BASE_URL": "https://modelfold.ai/anthropic",
    "ANTHROPIC_AUTH_TOKEN": "your_MODELFOLD_API_Key"
  }
}

Method C: CC-SWITCH ​

Installation Steps:

  • Download the CC-Switch-Windows.msi file.
https://github.com/farion1231/cc-switch/releases
  • Double-click to run the installer and follow the wizard to complete the installation.

  • After installation, find CC Switch in the Start Menu or on the desktop and launch it.

Enter the following information:

  • API KEY (No Bearer required)

  • Request URL 'https://modelfold.ai/anthropic' (It is recommended to disable the full URL)

  • Enter the corresponding model name from the ModelFold documentation in the advanced options.

Save and enable.


Choose a model and run a minimal check ​

Set the same key in the current shell for model discovery, then query the platform:

bash
export MODELFOLD_API_KEY="your_MODELFOLD_API_Key"
curl -fsS -H "Authorization: Bearer $MODELFOLD_API_KEY" \
  https://modelfold.ai/anthropic/v1/models

Copy an id from data[].id and replace MODEL_ID below. Do not assume the CLI default or a built-in alias is available:

bash
claude -p "Hello, reply briefly" --model "MODEL_ID"

In PowerShell, use $env:MODELFOLD_API_KEY and curl.exe for the listing. To persist a default model, add ANTHROPIC_MODEL to the env block of your user-level settings.json, using a discovered id.

A 200 model listing proves authentication and discovery, not generation availability. A 429 / Resources are tight, please try again later response indicates upstream resource pressure. A 400 Internal error, please try again later also means verification has not passed. Try later or select another listed model; repeatedly changing the key or switching BASE_URL back to /v1/anthropic will not fix these errors.

Step 3: Verify the Connection ​

Open a terminal and run in any directory:

bash
claude

Once the interactive session starts, send any message (e.g. "Hello").

  • ✅ Gets a normal reply → modelfold.ai is connected. You can also verify usage in the modelfold.ai logs page.
  • ❌ Prompted to log in with an Anthropic account → See FAQ item #1 below.

FAQ ​

SymptomCause / Solution
Still prompted to log in with Anthropic accountEnvironment variables not loaded. Fully close all terminal windows (Mac: right-click Terminal → Quit; Windows: close all PowerShell processes) and reopen.
401 Unauthorized errorAPI Key is wrong or expired. If using ANTHROPIC_AUTH_TOKEN, set it to the raw Key with no prefix. Check your key in the modelfold.ai dashboard.
Model not acceptedRun /model and pick an id listed by GET https://modelfold.ai/anthropic/v1/models.
Windows — changes still not workingClose all terminals, including built-in terminals in VSCode, Cursor, and other editors. Fully quit those apps and relaunch.

To inspect the actual requests Claude Code sends, start with claude --debug and review the detailed logs. Remove credentials, prompts and file contents before sharing logs.


Security Tips ​

  • Keep your API Key private — never share it in screenshots, chat groups, or code repositories.
  • If the settings file lives inside a project directory, add .claude/settings.json to .gitignore. Files placed in your home directory (~/.claude/) are safe by default.
  • If your key is compromised, reset it immediately from the modelfold.ai dashboard.

If you have any questions, feel free to reach out.

ModelFold — one API for all the best AI models.