Claude Code
During software development, developers often struggle with slow coding and complex debugging. Claude Code is an AI programming tool that helps developers write and debug code efficiently using large language models. However, quickly adding these advanced AI capabilities to existing development environments has become a new challenge. You can easily connect MaaS model APIs to Claude Code using simple settings to quickly integrate API capabilities and improve your development speed.
Prerequisites
You have subscribed to built-in services or created an endpoint. For details, see Subscribing to Built-in Services or Creating an Endpoint.
Billing
When using the MaaS service, you are charged based on the number of tokens used. For details, see Text Generation Models.
Constraints
This function is only supported in the CN-Hong Kong region.
Step 1: Install Claude Code
- Install Node.js 18 or later.
- Install Git for Windows (for Windows users only).
- Open the command-line interface and run the following command to install Claude Code:
npm install -g @anthropic-ai/claude-code
- After the installation, run the following command to check whether the installation is successful:
claude --version
If the version number appears, the installation is successful.
Step 2: Configure MaaS Model APIs in Claude Code
After installing Claude Code, configure the following parameters:
| Parameter | Description |
|---|---|
| ANTHROPIC_BASE_URL | https://api-ap-southeast-1.modelarts-maas.com/anthropic |
| ANTHROPIC_AUTH_TOKEN | |
| ANTHROPIC_MODEL | For details about the supported models and model parameter values, see supported models. |
- Edit the settings.json file and update the following parameters.
- <API_KEY>: Replace it with your own API key.
- <Model_Name>: Replace it with the model to be used, for example, glm5. For details about supported models, see supported models.
{ "env": { "ANTHROPIC_AUTH_TOKEN": "<API_KEY>", "ANTHROPIC_BASE_URL": "https://api-ap-southeast-1.modelarts-maas.com/anthropic", "ANTHROPIC_MODEL": "<Model_Name>", "ANTHROPIC_DEFAULT_HAIKU_MODEL": "<Model_Name>", "ANTHROPIC_DEFAULT_SONNET_MODEL": "<Model_Name>", "ANTHROPIC_DEFAULT_OPUS_MODEL": "<Model_Name>" } }
The configuration file path varies depending on your operating system. Run the command for your specific system. If the settings.json file does not exist, create it in the corresponding directory.
- macOS/Linux: nano ~/.claude/settings.json
- Windows: C:\Users\Your username\.claude\settings.json
- Save the configuration file and open a new terminal to apply the changes.
Step 3: Use Claude Code
- Start Claude Code. Open the terminal, navigate to the project directory, and run the claude command to start using Claude Code.
claude
Once it starts, trust the folder to let Claude Code access files in the directory.
- Run /status to verify the model status. Figure 1 Viewing the model status
- Start a conversation in Claude Code. Figure 2 Example conversation
Helpful Links
- Viewing the Call Data and Monitoring Metrics of Real-Time Inference on MaaS: MaaS tracks call statistics so you can view usage and monitoring metrics of models for any specific period. You can use these details to evaluate model performance, locate and troubleshoot faults, and optimize your services.
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot