AGTCloud API Docs
GuidesAPI ReferenceIntegrations and resourcesUpdate and help

Claude Code

Configure and use AGTCloud in Claude Code.

Claude Code is a terminal programming tool launched by Anthropic. By configuring the API address, API Key, and model ID, Claude Code can use AGTCloud's Anthropic Messages compatible entry point.

This guide covers the Claude Code CLI. Support for tool calls, extended thinking, and experimental features varies by model, so choose a model that is available to the current API Key and supports Anthropic Messages.

Preparation

Before you start, please confirm that you have:

  • Prepare your terminal environment and Git;
  • Register and log in to AGTCloud;
  • Create a token on the API Keys page;
  • Find a model ID that is available to the current token and supports the Anthropic protocol in the Model Marketplace.

Install Claude Code

Choose the installation method that matches your operating system. The native installation script will update automatically; Homebrew and WinGet installation require manual updates through their respective package managers.

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

After installation, reopen the terminal and check the version:

claude --version
claude doctor

claude doctor checks the installation and configuration. If the terminal cannot find claude, reopen it and confirm that the installation directory is in PATH.

Configure AGTCloud

Claude Code sends requests to ANTHROPIC_BASE_URL. Enter only the AGTCloud API Origin; do not append /v1, because Claude Code automatically requests /v1/messages.

Temporary configuration

The following configuration applies only to the current terminal session. Replace your-api-key and MODEL_ID with your API Key and model ID.

unset ANTHROPIC_AUTH_TOKEN
export ANTHROPIC_BASE_URL="https://api.agtcloud.cn"
export ANTHROPIC_API_KEY="your-api-key"
export ANTHROPIC_MODEL="MODEL_ID"
Environmental variablesFunction
ANTHROPIC_BASE_URLPoint the Claude Code request to the AGTCloud API address shown on this page
ANTHROPIC_API_KEYSends the AGTCloud API Key in the x-api-key header
ANTHROPIC_MODELSpecify the model ID to be used by default for this session

Clearing conflicting authentication variables

If ANTHROPIC_AUTH_TOKEN is set, Claude Code may use it as a Bearer token instead of ANTHROPIC_API_KEY. Clear the conflicting variable before applying this guide.

Durable configuration

If you want the settings to load automatically whenever you open a terminal, add the same values to your shell configuration file or Windows user environment variables. The API Key will be stored locally as plaintext, so use this method only on a trusted personal device.

Edit ~/.zshrc and add:

export ANTHROPIC_BASE_URL="https://api.agtcloud.cn"
export ANTHROPIC_API_KEY="your-api-key"
export ANTHROPIC_MODEL="MODEL_ID"

Load configuration after saving:

source ~/.zshrc

Choose a model

MODEL_ID is a placeholder, not a real model name. From the Model Marketplace, copy the full ID of a model that is available to the current API Key and supports Anthropic Messages.

In Claude Code, run /model to view and switch the session model. Whether the selector lists every AGTCloud model depends on the Claude Code version and current API Key. If the target model is absent, set its full ID with ANTHROPIC_MODEL.

Claude Code's model selection interface

Start and verify the connection

Enter the project directory

cd /path/to/your/project

Launch Claude Code

claude

If the first startup prompts whether to use the API Key from the environment variable, please confirm as prompted in the terminal.

Check the current configuration

Executing in Claude Code:

/status

Confirm that the authentication source is an API Key and check whether the Base URL is the AGTCloud API address shown on this page. The Base URL should not contain duplicate /v1.

Initiate read-only tests

In a test project containing README.md, enter:

Please read the README.md and summarize the purpose of this project in three points. Do not modify any files.

If the content returns normally and the corresponding call record appears in the AGTCloud console, it means the basic connection has been established.

Claude Code terminal interface

After completing the configuration check, you can send a simple question to confirm that the model responds correctly.

Claude Code Basic Dialogue Test

Frequently Asked Questions

IssueWhat to checkResolution
The claude command is not foundInstallation and PATHReopen the terminal and run claude doctor; rerun the official installer if necessary
Login is still required after startupWhether the API Key is active in the same terminal where Claude Code is launchedCheck the ANTHROPIC_API_KEY, reopen the terminal, and restart it
The API Key is not activeWhether ANTHROPIC_AUTH_TOKEN is also setClear conflicting variables and use /status to verify the authentication source
Returns 401API Key, environment variables, and token statusCopy a valid API Key again and use /status to confirm the authentication source
Returns 403Token permissions, model permissions, and account statusCheck the token status and the models available to the account in the console
Returns 404Base URL and model IDUse https://api.agtcloud.cn as the Base URL without appending /v1, then copy the model ID again
Models cannot be found or unusablemodels available to the current API Key and protocol supportSelect a model that supports Anthropic Messages and specify the full ID via the ANTHROPIC_MODEL
Some tools or advanced features are unavailableModel capabilities and gateway compatibilityStart with a basic conversation. Advanced capabilities depend on the selected model and the current integration support

If you cannot identify an issue, record the request time, model ID, HTTP status, and redacted error message, then review Errors and troubleshooting. Never submit the full API Key.

Safety advice

  • Create a separate API Key for Claude Code to facilitate permission management and disable credentials.
  • Do not write real keys into code, repositories, screenshots, logs, or shared scripts.
  • In shared devices or team environments, prioritize operating system credential management or organize a unified key distribution scheme.
  • If an API Key is suspected of leaking, it should be immediately disabled or removed in the console and a new Key created.

Next, you can continue reading API Key, Base URL & Authentication and Anthropic Messages.

On this page