Skip to main content

Guide to Using Claude Code CLI with AGIPower

Claude Code is Anthropic’s official Coding Agent. With AGIPower integration, you can access a broader set of model options instead of being limited to Anthropic’s official Claude models.For example, via AGIPower you can use GPT-5.2 series, Claude-4.5 series, Gemini-3 series, Grok 4.1 series, Doubao-Seed-Code, Kimi-K2, Minimax-M2, GLM-4.6, DeepSeek-V3.2, Qwen3-Coder-Plus, and more in Claude Code. For the full list of supported models, see the official model list.AGIPower fully supports the Anthropic API protocol and can be seamlessly integrated into tools like Claude Code and Cursor. You only need to change two parameters to use it.Note: the Anthropic-compatible base_url="https://agipower.ai".

Configuration Options

Install Claude Code

The npm/pnpm installation method for Claude Code has been deprecated and is 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):
Recommended installation (native install):
macOS/Linux/WSL
Windows PowerShell
Windows CMD
Homebrew (macOS)
WinGet (Windows)
  • Native install (recommended): The script-based installers for macOS/Linux/WSL and Windows auto-update so you always stay on the latest version.
  • Package manager install: Homebrew and WinGet require you to run the update command manually to get new versions.
  • Full installation docs: For detailed install options, system requirements, auth methods, and more, see the official Claude Code installation docs.
  • Verify installation: After installation, run claude doctor to check the installation status.

Configure Claude Code

How the Configuration Works

By default, Claude Code connects directly to Anthropic’s official service. However, by configuring environment variables, we can redirect its requests to AGIPower. This provides several benefits:
  • No changes to Claude Code itself: Switch endpoints using only environment variables
  • Authenticate with a AGIPower API Key: Replaces Anthropic’s official API key
  • More model choices: In addition to Claude, you can use GPT, Gemini, Qwen, and more
The core configuration is to set two key environment variables: ANTHROPIC_BASE_URL (the AGIPower endpoint) and ANTHROPIC_AUTH_TOKEN (your AGIPower API Key), so that all Claude Code requests are proxied through AGIPower.
Due to updates in Claude Code v2.0.7x, its environment-variable loading logic has changed: the env config in ~/.claude/settings.json cannot be reliably read in the following scenarios:
  • When logging in for the first time in Claude Code
  • When logging in again after running logout
Therefore, when connecting to AGIPower, it’s recommended to standardize on shell profile environment variables to ensure both login and requests go through AGIPower’s Anthropic-compatible endpoint.

Step 0: Get a AGIPower API Key

Before configuring Claude Code, you need a AGIPower API Key. AGIPower offers two billing options—choose based on your use case:
Subscription API Key (Recommended)
Pay-as-you-go API Key
  • Personal development / learning → Use a Subscription API Key (sk-ss-v1-xxx) for lower, better value cost
  • Production / commercial projects → Use a Pay-as-you-go API Key (sk-xxx) for higher stability and no limits
Subscription keys are not allowed for production use. Violations may result in account restrictions.
This step writes the AGIPower connection configuration into your shell config file so it automatically applies whenever you open a terminal.
macOS/Linux
Windows PowerShell
Be sure to replace sk-ss-v1-xxx or sk-xxx in the configuration with your real AGIPower API Key:Subscription API Key (recommended for personal development)Pay-as-you-go API Key (production)

Step 2: Launch Claude Code and Complete Authentication

After the environment variables are configured, you can start Claude Code. On first launch, it will automatically authenticate via AGIPower. Steps:
  1. Open a new terminal window (to ensure the environment variables are loaded)
  2. Go to your project directory:
  3. Start Claude Code:
  4. On first launch, Claude Code will:
    • Automatically read ANTHROPIC_AUTH_TOKEN from your environment variables
    • Authenticate via the AGIPower endpoint specified by ANTHROPIC_BASE_URL
    • Start working immediately, with no additional login steps
If you see an error that the claude command cannot be found, confirm that Claude Code is installed globally (see the installation steps above).

Step 3: Verify the Connection

After launching successfully, it’s recommended to verify that Claude Code is correctly connected to AGIPower. In the Claude Code prompt, run /status and check whether the configuration is correct:
What to verify:
  • Auth token should display ANTHROPIC_AUTH_TOKEN (meaning it’s read from environment variables)
  • Anthropic base URL should display https://agipower.ai (the AGIPower endpoint)
If everything matches, your setup is complete—you can now use Claude Code through AGIPower.

Switch / Set Default Models

You’ve already configured the default models in your shell profile (required). If you want to switch to other models, just update the same set of environment variables:
After editing, remember to run source ~/.bashrc / source ~/.zshrc or restart the terminal for changes to take effect.

Supported Models

Models compatible with the Anthropic protocol are being adapted in batches. You can filter currently supported models via the official model list and select the Anthropic Messages protocol: anthropic-support Or you can check support on a specific model detail page: anthropic-support

Use the Claude Code Extension in VSCode

In addition to the CLI, Claude Code also provides a VSCode extension, allowing you to use Claude Code directly inside the VSCode editor for AI-assisted programming.

Step 1: Install the Claude Code Extension

Search for and install Claude Code Extension from the VSCode Marketplace: <div style=“text-align: center;”> Install Claude Code Extension </div>

Step 2: Open Settings

After installation, click the extension’s Settings icon to open the configuration page: <div style=“text-align: center;”> Open Claude Code settings </div>

Step 3: Configure the Model and Environment Variables

Click Edit in settings.json, then add or modify the following configuration: <div style=“text-align: center;”> Configure model and environment variables </div>
  1. Replace the API Key: Replace sk-ss-v1-xxx with your real AGIPower API Key
    • Subscription API Key (sk-ss-v1-xxx): best for personal development
    • Pay-as-you-go API Key (sk-xxx): best for production
  2. Configuration priority:
    • If you previously configured shell environment variables in the CLI (~/.bashrc / ~/.zshrc / PowerShell Profile), the VSCode extension will prefer the settings.json configuration
    • To avoid conflicts, when using the VSCode extension, configure environment variables only in settings.json
  3. Model selection:
    • claudeCode.selectedModel sets the model currently in use
    • ANTHROPIC_DEFAULT_*_MODEL sets the default models for the three speed tiers
    • You can switch models during a session using the /model command

Step 4: Start Using It

After configuration, you can use the Claude Code extension in VSCode:
  1. Click the Claude Code icon in the VSCode sidebar
  2. Enter your question or task in the chat panel
  3. Claude will automatically read project files and help you
  • Trust the workspace: On first use, Claude Code will ask you to trust the current workspace—click Trust This Folder to allow access to project files.
  • Switch models: Type /model during a conversation to view the current model or switch to another.
  • Check status: Type /status to see the current connection status and configuration.
  • Environment variable conflicts: If you run into auth issues, confirm ANTHROPIC_AUTH_TOKEN and ANTHROPIC_BASE_URL are not being overridden by system-level environment variables.

What It Looks Like

After setup, you can use multiple AGIPower models in Claude Code: <div style=“text-align: center;”> Claude Code </div> You can use the ‘/model’ command to confirm which model is currently in use: <div style=“text-align: center;”> Claude Code Model </div>

Troubleshooting

Common Issues

API Key Error or Authentication Failure

Issue: You see messages like “invalid API key,” “unauthorized,” or authentication failed. Solution:
  1. Check the API Key format:
    • Subscription API keys should start with sk-ss-v1-
    • Pay-as-you-go API keys should start with sk-
    • Ensure there are no extra spaces or newline characters
  2. Validate the API Key:
  3. Confirm environment variables are loaded:
    If the output is empty, the environment variables were not loaded correctly. Re-run source ~/.zshrc or restart the terminal.
  4. Check the API Key status:
    • Confirm the API key is shown as “Enabled” in the console
    • Check whether the API key has been deleted or disabled
  5. Get a new API Key:

Authentication Failure When Switching from Another Platform to AGIPower

Issue: You previously used a Claude Code official account or another platform (e.g., MiniMax, GLM, etc.). After switching to AGIPower, authentication fails or configuration conflicts occur. Solution: This usually happens because old config files cached prior authentication info, causing conflicts with the new AGIPower configuration. Clean up and reconfigure as follows:
  1. Delete the old config file:
    [macOS/Linux]
    [Windows PowerShell]
  2. Confirm your shell environment variables are configured correctly: Check whether your shell config file (~/.zshrc or ~/.bashrc) contains the full AGIPower configuration. Refer to the Step 1: Configure Shell Environment Variables section above, and ensure it includes these key variables:
  3. Reload environment variables:
    [Using zsh]
    [Using bash]
    [Windows PowerShell]
  4. Verify environment variables are applied:
    [macOS/Linux]
    [Windows PowerShell]
  5. Restart Claude Code:
  6. Verify the connection: After starting, run /status in Claude Code and confirm it shows:

The Model Does Not Support the Anthropic Protocol

Issue: When using a model, you see a message saying it does not support the Anthropic protocol. Solution:
  • Use the AGIPower model list and filter by “Anthropic API Compatible” to see currently supported models
  • Or open the model’s detail page to confirm Anthropic protocol support
  • Choose a model from the supported list above

Connection Failures

Issue: Claude Code cannot connect to the AGIPower service. Solution:
  • Check that your network connection is working
  • Verify ANTHROPIC_BASE_URL is set to https://agipower.ai
  • Confirm your firewall is not blocking outbound connections

VSCode Claude Code Extension Configuration Issues

Issue: In the VSCode Claude Code extension, you encounter issues such as authentication failures or models not working. Solution:
  1. Confirm the environment variables are configured correctly:
    • Open VSCode Settings (Cmd/Ctrl + ,)
    • Search for “Claude Code”
    • Click “Edit in settings.json”
    • Confirm claudeCode.environmentVariables includes correct ANTHROPIC_BASE_URL and ANTHROPIC_AUTH_TOKEN
  2. Check the model configuration:
    • Search for “claude-code.selectedModel” in Settings
    • Confirm the model name format is correct (e.g., anthropic/claude-sonnet-4.5)
    • Confirm the model supports the Anthropic protocol (check via the model list)
  3. Resolve environment variable conflicts:
    • The VSCode extension’s settings.json configuration has higher priority than system environment variables
    • If you previously set environment variables in your shell profile, it’s recommended to keep only one source of configuration
    • Avoid setting ANTHROPIC_AUTH_TOKEN in multiple places, which can cause conflicts
  4. Restart VSCode:
    • After changing configuration, fully quit and relaunch VSCode
    • Reopen the project so the new configuration takes effect
  5. Check extension logs:
    • Open the Output panel in VSCode (View > Output)
    • Select the “Claude Code” channel
    • Review detailed error messages to help diagnose the issue
  6. Verify the connection:
    • In the Claude Code chat UI, type /status
    • Confirm the displayed API endpoint and authentication method are correct
For detailed configuration steps, see the Use the Claude Code Extension in VSCode section above.

Windows PowerShell Script Execution Policy Issue

Issue: PowerShell shows: “Cannot load file xxx because running scripts is disabled on this system.” Solution: This is a Windows PowerShell security mechanism. You need to change the execution policy:
  1. Run PowerShell as Administrator
  2. Execute:
  3. Type Y to confirm
  4. Reopen the PowerShell window
Execution policy reference:
  • Restricted (default): no scripts can run
  • RemoteSigned: local scripts can run; downloaded scripts require a digital signature
  • Unrestricted: all scripts can run (not recommended)

Windows: claude Command Not Found

Issue: After installing Claude Code, PowerShell cannot find the claude command. Solution: This is usually caused by the npm global package path not being added to the PATH environment variable.
  1. Check the npm global prefix:
  2. Check whether that path is in PATH:
  3. If it isn’t, add it manually (choose one): Option 1: Temporary (current session only)
    Option 2: Permanent (recommended)
  4. Close and reopen PowerShell
  5. Verify the installation:

Windows PowerShell Profile Not Taking Effect

Issue: You configured the PowerShell Profile, but the environment variables are not loaded. Solution:
  1. Confirm the Profile file path is correct:
  2. Confirm the Profile file exists:
  3. Confirm the Profile file content is correct:
  4. Manually load the Profile (to test for syntax errors):
  5. If errors occur, check:
    • Whether the file encoding is UTF-8
    • Whether the PowerShell syntax is correct (note the $env: prefix)
    • Whether the execution policy allows scripts (see “PowerShell Script Execution Policy Issue” above)
  6. Verify environment variables are loaded:

How to Enable the 1M Context Window

Issue: The 1M context window is not enabled when using anthropic/claude-opus-4.6 or anthropic/claude-sonnet-4.6. Cause: Claude Code determines whether to enable the extended context window based on the model name. Model names with the anthropic/ prefix are not recognized, causing it to fall back to the default context window size. Solution: Replace the model names with the format that Claude Code can recognize:
  • anthropic/claude-opus-4.6claude-opus-4-6
  • anthropic/claude-sonnet-4.6claude-sonnet-4-6
After making the change, reload your config with source ~/.zshrc or source ~/.bashrc, then restart Claude Code.

Windows: Chinese Characters in Environment Variables

Issue: Garbled text appears when environment variables contain Chinese paths or values. Solution:
  1. Ensure the PowerShell Profile file uses UTF-8 with BOM encoding
  2. Set the correct encoding in PowerShell:
  3. If the issue persists, avoid using Chinese characters in environment variable values
See the AGIPower model list for all available models and detailed information.
If you run into any issues or have suggestions/feedback, feel free to contact us via:For more contact options and details, visit our Contact Us page.