Terminal-native AI programming tools are becoming more common among developers. Claude Code is one of the most practical options in this category. It supports code generation, debugging, refactoring, project analysis, and daily development assistance directly from the command line.
However, the official Claude Pro plan may create cost pressure for heavy users. Developers who use AI coding tools every day often need higher quotas and more stable access. GLM Coding Plan from Zhipu AI provides another option. It allows developers to use GLM models through a Claude Code-compatible configuration, while keeping the original terminal workflow largely unchanged.
This guide explains how to configure Claude Code with GLM Coding Plan. It covers environment preparation, installation steps, API key setup, model mapping, long-context configuration, effort mode selection, quota rules, MCP extensions, and common troubleshooting methods.
1. Core Advantages of GLM Coding Plan
GLM Coding Plan is an AI coding subscription package based on Zhipu AI’s GLM model family. Through API adaptation, it can work with Claude Code and provide a coding experience close to the original Claude Code workflow.
Its advantages mainly come from four areas.
First, GLM Coding Plan provides higher call quotas under similar pricing conditions. For developers who use AI coding tools frequently, this can reduce the risk of quota exhaustion and lower long-term usage pressure.
Second, it supports transparent model mapping. After configuration, Claude Code may still display Claude-style model names. In the backend, however, the actual requests are routed to GLM models such as GLM-4.7 and GLM-5.2. Developers do not need to change their command-line habits.
Third, GLM-5.2 supports a 1 million-token context window. This is useful for large repositories, multi-file projects, long technical documents, and complex engineering tasks. A larger context window can help the model understand more project information in one session.
Fourth, GLM Coding Plan supports MCP server extensions. These extensions can add visual analysis, online search, and web content parsing to Claude Code. As a result, the tool is no longer limited to simple code generation.
This combination is suitable for individual developers who care about cost efficiency. It is also useful for teams that need domestic model access and a familiar terminal coding workflow.
The recommended software version is Claude Code 2.1.140 or later. The main GLM models used in this setup include GLM-5.2 and GLM-5-Turbo, both of which are optimized for coding-related scenarios.
2. Pre-Deployment Environment Requirements
Before installing Claude Code, developers should prepare the required runtime environment. This helps avoid permission issues, command errors, and version conflicts.
The setup applies to macOS, Linux, and Windows. The required components are Node.js and Git.
Node.js must be version 18 or later. Claude Code runs as a command-line program based on the Node.js ecosystem. Git is also required for repository operations, code tracking, and common development workflows.
For Windows users, Git for Windows should be installed separately. After installation, make sure both node and git can be accessed from the terminal.
For macOS users, it is better not to install Node.js directly through the official PKG package if permission errors appear later. Two recommended methods are Homebrew and nvm.
Homebrew installation:
brew install node
nvm installation:
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.0/install.sh | bash
Linux users can install Node.js and Git through their usual package manager. After the environment is ready, the Claude Code installation can begin.
3. Installation and Basic Configuration
3.1 Install and Verify Claude Code
Claude Code is distributed as a global NPM package. Open a terminal and run:
npm install -g @anthropic-ai/claude-code
After installation, check the version:
claude --version
If the output is similar to the following, the installation is successful:
2.1.140 (Claude Code)
One important detail should be noted. Do not start Claude Code immediately after installation if the API has not been configured. By default, the client may try to connect to Anthropic’s official service. This may fail in some network environments. Complete the GLM Coding Plan configuration first, then launch Claude Code.
3.2 Register a Zhipu AI Account and Get an API Key
The API Key is the credential used to connect Claude Code with GLM models. It controls access permission and quota usage.
First, register and log in to the Zhipu AI Open Platform. Individual users can obtain a key from the personal programming package page. Team users can enter the team programming package section and get the team API Key from the package management page.
The API Key should be handled like a password. Do not expose it publicly. Do not hard-code it into project files. This can prevent account abuse and unexpected quota consumption.
3.3 Configure Environment Variables
There are three common ways to configure environment variables: one-click configuration, script-based configuration, and manual configuration.
The recommended method is to use Coding Tool Helper from Zhipu AI. Run the following command:
npx @z_ai/coding-helper
Then follow the prompts. The tool can detect the local environment, bind the API Key, configure model mapping, and manage related settings. This is the easiest option for most users.
The second method is automated script deployment. It is suitable for developers who prefer command-line batch setup. The official script can write environment variables and model adaptation rules automatically.
The third method is manual configuration. This gives users more control over each parameter.
For macOS and Linux, edit ~/.zshrc, ~/.bash_profile, or the shell configuration file you use. Add the following lines:
export ANTHROPIC_API_KEY="your_glm_api_key_here"
export ANTHROPIC_BASE_URL="https://open.bigmodel.cn/api/paas/v4"
For Windows PowerShell, run:
$env:ANTHROPIC_API_KEY="your_glm_api_key_here"
$env:ANTHROPIC_BASE_URL="https://open.bigmodel.cn/api/paas/v4"
After manual configuration, close all existing terminal windows. Then open a new terminal so the environment variables can take effect.
3.4 Launch Claude Code
After the environment variables are ready, enter your project directory and run:
claude
During the first launch, Claude Code may show two authorization prompts.
The first prompt asks whether to use the current API Key. Select “Yes”.
The second prompt asks whether to trust the current folder. Claude Code needs permission to read local files and run development commands. If this is your own project directory, select “Yes, proceed”.
After these steps, Claude Code enters the working state. You can now use natural language instructions for coding tasks.
4. Advanced Model Configuration and Long Context
4.1 Default Model Mapping
After basic configuration, Claude Code can use automatic model mapping. The interface may still show Claude-style model names, while the backend calls GLM models.
The common mapping relationship is:
claude-opus-4→ GLM-4.7claude-sonnet-4→ GLM-4.7claude-haiku-3→ GLM-4.5-Air
This default setup is enough for many daily coding tasks. For lightweight usage, no extra adjustment is required.
4.2 Enable GLM-5.2 and 1 Million-Token Context
For complex projects, developers may want stronger reasoning and longer context. In that case, GLM-5.2 with a 1 million-token context window can be enabled manually.
Open the Claude Code user configuration file:
~/.claude/settings.json
Write the following configuration:
{
"env": {
"CLAUDE_CODE_AUTO_COMPACT_WINDOW": "1000000",
"ANTHROPIC_DEFAULT_HAIKU_MODEL": "glm-4.5-air",
"ANTHROPIC_DEFAULT_SONNET_MODEL": "glm-5.2[1m]",
"ANTHROPIC_DEFAULT_OPUS_MODEL": "glm-5.2[1m]"
}
}
Two parameters are especially important.
The [1m] suffix after glm-5.2 is required. Without this suffix, the 1 million-token context window may not be activated.
CLAUDE_CODE_AUTO_COMPACT_WINDOW should also be set to 1000000. This allows Claude Code to match the long-context setting and manage context compression properly.
If you see a “model does not exist” error, your Claude Code version may be too old. Run:
claude update
Then restart the terminal and try again.
4.3 Verify the Model Configuration
After restarting Claude Code, enter the following command in the interactive session:
/status
If the result shows glm-5.2[1m] and the context window is marked as 1,000,000 tokens, the configuration is active.
This command is also useful for daily checks. When you are unsure which model is being used, /status is the most direct verification method.
5. Effort Modes and Quota Rules
5.1 Effort Level Mapping
Claude Code supports different effort modes. These modes control the model’s reasoning intensity. In GLM Coding Plan, the modes are mapped to GLM-5.2 reasoning levels.
The low, medium, and default high modes are usually mapped to the high level of GLM-5.2. These modes are suitable for quick Q&A, simple code generation, and daily development tasks.
The xhigh, max, and ultracode modes are mapped to the max level of GLM-5.2. These modes are better for architecture design, complex logic implementation, and difficult debugging tasks.
To switch the reasoning level, enter:
/effort max
For complex engineering tasks, max mode can improve the first-pass quality of generated code. It may also reduce repeated revisions.
5.2 Quota Consumption Rules and Cost Control
Quota consumption for GLM-5.2 and GLM-5-Turbo follows time-based rules under UTC+8.
The peak period is from 14:00 to 18:00 every day. During this period, the consumption coefficient is 3x. Each call deducts three times the base quota.
Other periods are considered off-peak hours. The standard coefficient is 2x. During the limited-time discount period before the end of September, off-peak usage is reduced to 1x.
Based on these rules, developers can use several practical cost-control methods.
First, avoid the 14:00–18:00 peak period when possible. Morning and evening sessions are usually more cost-effective.
Second, choose models based on task difficulty. Use GLM-4.5-Air or GLM-4.7 for simple tasks. Reserve GLM-5.2 for complex reasoning or large-context work.
Third, use max mode selectively. Although a single max call may consume more quota, it can reduce repeated failed attempts for difficult tasks.
6. MCP Server Extensions
GLM Coding Plan supports the MCP protocol. It can extend Claude Code from a coding assistant into a broader development tool.
The main MCP extensions include vision, search, and web reading.
The vision MCP server supports image recognition and visual analysis. Developers can upload UI screenshots, architecture diagrams, or flowcharts. The model can analyze layout problems, extract visual information, and generate related code.
The search MCP server provides online search. It can help query technical documents, framework updates, and community solutions. This is useful when the model’s built-in knowledge is not enough.
The web reading MCP server can parse web pages. It can extract tutorials, sample code, and technical specifications from specified URLs. The extracted information can then be used as coding context.
After MCP servers are configured, developers can call these tools with natural language instructions inside Claude Code. For example, they can ask the tool to search for the latest framework documentation, read a technical article, or analyze a UI screenshot.
7. Common Problems and Solutions
During long-term use, developers may encounter configuration or compatibility issues. The following problems are common.
7.1 Claude Code 2.1.69 Has Function Issues
Claude Code 2.1.69 may fail to call certain models, including claude-opus-4. To solve this, add the following environment variables:
export ENABLE_TOOL_SEARCH=0
export CLAUDE_CODE_DISABLE_EXPERIMENTAL_BETAS=1
Then restart Claude Code.
7.2 settings.json Does Not Take Effect
If changes to settings.json do not work, try the following steps.
First, close all running Claude Code processes. Then open a new terminal and restart the client.
Second, check whether the JSON format is valid. Missing commas or unmatched brackets can cause the configuration to fail.
Third, delete the old settings.json file and reconfigure the environment. Claude Code can generate a new standard configuration file.
7.3 Unable to Confirm the Current Model
Use the following command:
/status
The returned information will show the current model name and context window. This is the most reliable way to confirm the running model.
7.4 Version Selection
It is recommended to use the latest official Claude Code version. Version 2.1.140 or later is considered a stable choice for this setup.
You can update Claude Code with:
claude update
Regular updates help maintain compatibility with new models and new features.
8. Summary
Claude Code combined with GLM Coding Plan provides a cost-effective terminal AI programming workflow. It keeps the familiar Claude Code interaction style while using GLM models in the backend.
The main benefits include higher call quotas, domestic model access, transparent model mapping, GLM-5.2 long-context support, and MCP extensions. For large repositories and complex coding tasks, the 1 million-token context window can be especially useful.
From a deployment perspective, the process includes environment preparation, Claude Code installation, API key configuration, model mapping, long-context activation, effort mode selection, and troubleshooting. The setup offers both automatic and manual configuration options, so users can choose the method that best matches their workflow.
For daily development, developers should also pay attention to quota rules. Avoiding peak hours, selecting models by task difficulty, and using max mode only when needed can help control cost.
For individual developers and teams that need a stable domestic AI coding solution, GLM Coding Plan can be a practical alternative to foreign premium coding subscriptions. With proper configuration, it can improve coding, debugging, refactoring, and project analysis efficiency in real development work.




