Skip to main content

Claude Code

Claude Code is Anthropic’s official coding agent. By integrating it with ShuYou, you gain access to a much wider range of models—not just Anthropic’s Claude lineup.For example, through ShuYou you can use GPT, Claude, Gemini, and other models that support the Anthropic Messages protocol directly inside Claude Code. For the full list, see the ShuYou model list.ShuYou fully supports the Anthropic Messages API, so it integrates seamlessly into tools like Claude Code and Cursor. Just change two parameters to get started.Anthropic protocol base URL: https://api.shuyou.ai

Configuration

Installing Claude Code

The npm/pnpm install method for Claude Code is deprecated and no longer recommended. If you previously installed Claude Code via npm/pnpm, uninstall the old version first, then use the new native installation method.Uninstall the old version (if applicable):
npm uninstall -g @anthropic-ai/claude-code
# or
pnpm uninstall -g @anthropic-ai/claude-code

# If you're already on a native install, you can run the migration command directly
claude install
Recommended installation (native install):
curl -fsSL https://claude.ai/install.sh | bash
  • Native install (recommended): Script-based installs for macOS/Linux/WSL and Windows auto-update.
  • Package manager install: Homebrew and WinGet require manual upgrade commands.
  • Full installation docs: See the official Claude Code installation docs.
  • Verify the install: After installation, run claude doctor.

Configuring Claude Code

How the configuration works

By default, Claude Code connects directly to Anthropic’s official service. By setting a few environment variables, we can redirect its requests to ShuYou instead. The benefits are:
  • No changes to Claude Code itself: You switch the service endpoint purely through environment variables.
  • Authenticate with a ShuYou API Key: Used in place of an official Anthropic API Key.
  • Access more models: Beyond the Claude series, you can also use GPT, Gemini, and other Anthropic-compatible models on ShuYou.
The core of the setup is two key environment variables: ANTHROPIC_BASE_URL (https://api.shuyou.ai) and ANTHROPIC_AUTH_TOKEN (your ShuYou API Key). Together they route all of Claude Code’s requests through ShuYou.
Because of an update in Claude Code v2.0.7x, its environment-variable loading logic has changed: the env configuration in ~/.claude/settings.json cannot be reliably read in the following scenarios:
  • On the first login to Claude Code
  • When logging in again after a logout
For this reason, when connecting to ShuYou we recommend configuring everything via shell profile environment variables, ensuring that both login and requests go through ShuYou’s Anthropic-compatible endpoint.

Step 0: Get a ShuYou API Key

Before configuring Claude Code, you need a ShuYou API Key. ShuYou offers two billing plans—choose based on your use case:
  • Personal development / learning → use a subscription API Key for lower, more cost-effective pricing.
  • Production / commercial projects → use a Pay As You Go API Key for higher stability and no limits.
Subscription keys must not be used in production; misuse may result in account restrictions.
This step writes the ShuYou connection settings into your shell config file so they take effect automatically every time you open a terminal.
# 1. Determine which shell you use (usually bash or zsh):
#    - bash  → edit ~/.bashrc
#    - zsh   → edit ~/.zshrc
#    - run echo $SHELL to check

# 2. Append the following (replace YOUR_SHUYOU_API_KEY)

# ========= ShuYou + Claude Code configuration =========
export ANTHROPIC_BASE_URL="https://api.shuyou.ai"
export ANTHROPIC_AUTH_TOKEN="YOUR_SHUYOU_API_KEY"
export ANTHROPIC_API_KEY=""

export CLAUDE_CODE_DISABLE_EXPERIMENTAL_BETAS="1"
export CLAUDE_CODE_ATTRIBUTION_HEADER="0"
export CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC="1"

export API_TIMEOUT_MS="30000000"

# 3. Apply the configuration
source ~/.bashrc   # or source ~/.zshrc
# Or restart the terminal
Replace YOUR_SHUYOU_API_KEY with your real ShuYou API Key from the console.
VariableRequiredPurposeDescription
ANTHROPIC_BASE_URLYesService endpointRedirects Claude Code’s requests to ShuYou
ANTHROPIC_AUTH_TOKENYesAuthentication keyYour ShuYou API Key
ANTHROPIC_API_KEYYesConflict avoidanceSet to "" to avoid conflicts with an existing Anthropic config
CLAUDE_CODE_DISABLE_EXPERIMENTAL_BETASRecommendedPerformanceDisables experimental beta features to avoid long routing
CLAUDE_CODE_ATTRIBUTION_HEADERRecommendedPerformanceTurns off the attribution header
CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFICRecommendedTraffic controlDisables non-essential reporting
API_TIMEOUT_MSOptionalAPI timeoutRequest timeout in milliseconds
ANTHROPIC_DEFAULT_*_MODELOptionalModel mappingHaiku/Sonnet/Opus tiers; leave unset for Claude Code defaults
On non-first-party Anthropic-compatible gateways, experimental beta features can significantly increase request latency. Setting the three performance variables above improves speed and stability on ShuYou:
export CLAUDE_CODE_DISABLE_EXPERIMENTAL_BETAS="1"
export CLAUDE_CODE_ATTRIBUTION_HEADER="0"
export CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC="1"

Step 2: Launch Claude Code and authenticate

Once the environment variables are set, you can start Claude Code. On first launch, it authenticates automatically through ShuYou.
  1. Open a new terminal window (to ensure environment variables are loaded).
  2. Go to your project directory:
cd /path/to/your/project
  1. Launch Claude Code:
claude
  1. On first launch, Claude Code will:
    • Automatically read ANTHROPIC_AUTH_TOKEN from the environment variables
    • Authenticate via the ShuYou service pointed to by ANTHROPIC_BASE_URL
    • Be ready to use with no extra login steps
If you get a “command not found” error for claude, make sure Claude Code is installed (see the installation steps above).

Step 3: Verify the connection

At the Claude Code prompt, type the /status command:
> /status
Auth token: ANTHROPIC_AUTH_TOKEN
Anthropic base URL: https://api.shuyou.ai
What to check:
  • Auth token should show as ANTHROPIC_AUTH_TOKEN
  • Anthropic base URL should show as https://api.shuyou.ai
If the displayed information matches the above, the setup is successful.

Changing / specifying the default model

Configuring a default model is optional. If you don’t set ANTHROPIC_DEFAULT_*_MODEL, Claude Code uses its built-in default models. For official Claude models, we recommend the Claude model alias form (e.g., claude-opus-4-7, claude-sonnet-4-6, claude-haiku-4-5) rather than the full ShuYou model slug (anthropic/claude-sonnet-4.5):
export ANTHROPIC_DEFAULT_HAIKU_MODEL="claude-haiku-4-5"
export ANTHROPIC_DEFAULT_SONNET_MODEL="claude-sonnet-4-6"
export ANTHROPIC_DEFAULT_OPUS_MODEL="claude-opus-4-7"
Claude Code validates model names against hardcoded strings to enable features like the 1M context window and effort-based reasoning control. When the validator sees claude-sonnet-4-6, those features are activated; when it sees anthropic/claude-sonnet-4.5, validation may fail and features silently break.Use the alias form when available on the model detail page; otherwise use the full slug from the model list.

Using non-Claude models

When switching to a non-Claude model (such as GPT or Gemini), use the full ShuYou model slug:
export ANTHROPIC_DEFAULT_SONNET_MODEL="openai/gpt-4o"
export ANTHROPIC_DEFAULT_OPUS_MODEL="google/gemini-3.1-pro-preview"
After making changes, run source ~/.bashrc / source ~/.zshrc or restart your terminal. Switch models interactively with /model.

Supported models

Support for the Anthropic protocol is being rolled out in batches. Filter Anthropic API Compatible on the ShuYou model list:anthropic-supportYou can also check on a model detail page:anthropic-support

Using the Claude Code extension in VSCode

In addition to the command-line version, Claude Code offers a VSCode extension for AI-assisted coding inside the editor.

Step 1: Install the Claude Code extension

Search for and install Claude Code in the VSCode marketplace.

Step 2: Open the settings

After installation, click the extension’s settings icon, then choose Edit in settings.json.

Step 3: Configure the model and environment variables

{
  "claudeCode.selectedModel": "claude-sonnet-4-6",
  "claudeCode.environmentVariables": [
    { "name": "ANTHROPIC_BASE_URL", "value": "https://api.shuyou.ai" },
    { "name": "ANTHROPIC_AUTH_TOKEN", "value": "YOUR_SHUYOU_API_KEY" },
    { "name": "API_TIMEOUT_MS", "value": "3000000" },
    { "name": "CLAUDE_CODE_DISABLE_EXPERIMENTAL_BETAS", "value": "1" },
    { "name": "CLAUDE_CODE_ATTRIBUTION_HEADER", "value": "0" },
    { "name": "CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC", "value": "1" }
  ]
}
  1. Replace the API Key with your real ShuYou API Key.
  2. Configuration priority: The VSCode extension prioritizes settings.json over shell profile variables. When using the extension, configure environment variables in settings.json only to avoid conflicts.
  3. Model selection: claudeCode.selectedModel sets the current model. Use /model to switch mid-conversation.

Step 4: Start using it

  1. Click the Claude Code icon in the VSCode sidebar.
  2. Enter your question or task in the chat interface.
  3. Trust the workspace when prompted (Trust This Folder).
  • Switch models: Type /model mid-conversation.
  • Check status: Type /status to view connection status.
  • Environment variable conflicts: Ensure ANTHROPIC_AUTH_TOKEN and ANTHROPIC_BASE_URL are not overridden by system-level variables.

Troubleshooting

Problem: API Key invalid, unauthorized, or authentication failed.Solution:
  1. Verify the API Key is valid in the ShuYou console.
  2. Check subscription quota or Pay As You Go balance.
  3. Confirm environment variables are loaded:
# macOS/Linux
echo $ANTHROPIC_AUTH_TOKEN

# Windows PowerShell
echo $env:ANTHROPIC_AUTH_TOKEN
  1. Confirm the API Key is enabled and not deleted.
Problem: Previously used official Claude Code or another platform; switching to ShuYou causes conflicts.Solution:
  1. Delete the old config file:
# macOS/Linux
rm -rf ~/.claude/settings.json
# Windows PowerShell
Remove-Item -Path "$env:USERPROFILE\.claude\settings.json" -Force
  1. Re-apply the ShuYou shell environment variables from Step 1.
  2. Reload: source ~/.zshrc or . $PROFILE
  3. Verify:
echo $ANTHROPIC_BASE_URL    # Should output: https://api.shuyou.ai
echo $ANTHROPIC_AUTH_TOKEN  # Should output your ShuYou API Key
echo $ANTHROPIC_API_KEY     # Should output nothing
  1. Restart Claude Code and run /status.
Filter Anthropic API Compatible on the ShuYou model list, or check each model’s detail page.
  • Check network connectivity.
  • Verify ANTHROPIC_BASE_URL is https://api.shuyou.ai.
  • Confirm firewall is not blocking outbound connections.
  1. Open VSCode settings → search “Claude Code” → Edit in settings.json.
  2. Confirm claudeCode.environmentVariables contains correct ANTHROPIC_BASE_URL and ANTHROPIC_AUTH_TOKEN.
  3. For Claude models use alias form (e.g. claude-sonnet-4-6); for others use full ShuYou slug.
  4. Fully restart VSCode after changes.
  5. Check View → Output → Claude Code for errors.
  6. Run /status in the extension chat.
Run PowerShell as Administrator:
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser
Enter Y, then reopen PowerShell.
Cause: Claude Code validates model names against hardcoded strings. IDs with the anthropic/ prefix may not enable 1M context.Solution: Use alias form:
# Won't enable 1M context
export ANTHROPIC_DEFAULT_SONNET_MODEL="anthropic/claude-sonnet-4.5"

# Enables 1M context correctly
export ANTHROPIC_DEFAULT_SONNET_MODEL="claude-sonnet-4-6"
Reload shell config and restart Claude Code.
  1. Upgrade Claude Code to the latest version (Opus 4.7 requires v2.1.111+). Run claude --version.
  2. Set export ANTHROPIC_DEFAULT_OPUS_MODEL="claude-opus-4-7", or remove ANTHROPIC_DEFAULT_*_MODEL to use defaults.
  3. Reload config and restart Claude Code.
See the ShuYou model list for all available models.
Run Claude Code in a dedicated project folder. Avoid system directories or folders containing secrets.