Skip to main content

Claude Code

Claude Code is an AI that runs in the terminal. A programming agent can directly read local codebases, interact with developers using natural language, and autonomously complete complex development tasks such as code reading, multi-file modification, test execution, and command running.

After installing Claude Code, you can configure a custom model by following the steps below to use it, without needing to log in to an Anthropic account.

Prerequisites

  • You have activated a TCB environment and obtained the environment ID cloudBaseEnvID
  • Enable the required model in the AI console
  • Obtain the Base URL and API Key in the AI console
Base URLhttps://<ENV_ID>.api.tcloudbasegateway.com/v1/ai/cloudbase

Configuration Steps

This document uses Claude Code-v2.1.170 as an example.

Configuration Field Mapping Table

Environment VariableDescription
ANTHROPIC_BASE_URLThe Base URL for the large model, which is obtained in the AI console.
ANTHROPIC_AUTH_TOKENThe API Key for calling the large model, which is obtained in the AI console.
ANTHROPIC_MODELThe large model ID used for the main session. Copy the identifier of an enabled large model from the model list in the AI console and enter it here.
ANTHROPIC_DEFAULT_OPUS_MODELThe Opus large model ID. Copy the identifier of an enabled large model from the model list in the AI console and enter it here.
ANTHROPIC_DEFAULT_SONNET_MODELThe Sonnet large model ID. Copy the identifier of an enabled large model from the model list in the AI console and enter it here.
ANTHROPIC_DEFAULT_HAIKU_MODELThe Haiku large model ID. Copy the identifier of an enabled large model from the model list in the AI console and enter it here.

CC Switch is an open-source desktop application for centrally managing provider configurations for multiple AI coding tools. For installation instructions, refer to the CC Switch configuration guide.

  1. Open CC Switch and add CloudBase as a provider
FieldDescription
API KeyObtained from the AI console
Base URLhttps://{{cloudBaseEnvID}}.api.tcloudbasegateway.com/v1/ai/cloudbase
API FormatAnthropic Messages (default)
  1. Switch to the CloudBase provider and start Claude Code

Additional Configuration

You can find configuration instructions for more models on the Claude Code official website.

note

After connecting to a third-party model, the built-in web search feature in Claude Code becomes unavailable. If you require search capabilities, you can connect to the CloudBase AI Search Service via MCP.

Usage

Navigate to the specified directory in the terminal and enter the claude command to use the configured custom TCB large model. For more commands and features, refer to the official documentation.

claude

Claude Code

Common Error Troubleshooting

Error MessageSolution
429 Token usage exceeded quota limitTokens are exhausted or not enabled.
401 Credentials are invalidThe API Key is entered incorrectly or may have been deleted.
429 API Error: Request rejectedAn incorrect large model name is configured, or the large model is not enabled in the AI console.