How to Use GLM 4.7 with Claude Code and Cursor

A practical guide on how to use GLM 4.7 with Claude Code and Cursor, covering setup, configuration, comparisons, and API testing support.

Ashley Goolam

Ashley Goolam

26 December 2025

How to Use GLM 4.7 with Claude Code and Cursor

Today, software development increasingly depends on intelligent coding assistants that can understand context, reason about code, and accelerate delivery. GLM 4.7, developed by Z.AI, is one of the most advanced large language models optimized for coding tasks. When combined with tools such as Claude Code and Cursor, GLM 4.7 enables developers to generate, debug, and refactor code directly inside familiar workflows.

This guide explains how to use GLM 4.7 with Claude Code and Cursor, covering setup, configuration, and practical usage. It also touches on how tools like Apidog complement this workflow when testing API endpoints.

button

What Is GLM 4.7?

GLM 4.7 is Z.AI’s latest-generation coding model designed for:

Compared to earlier versions, GLM 4.7 offers improved reasoning depth and more stable outputs, making it suitable for professional development environments.

glm 4.7

Why Use GLM 4.7 with Claude Code and Cursor?

Claude Code and Cursor provide developer-friendly interfaces, while GLM 4.7 delivers the intelligence behind the scenes.

Together, they allow you to keep your existing habits while upgrading the quality of AI assistance.

Prerequisites: Getting a Z.AI API Key

Both Claude Code and Cursor require a Z.AI API key to access GLM 4.7.

Steps to Get the API Key

  1. Visit the Z.AI Open Platform
  2. Register or log in
  3. Navigate to API Keys
  4. Create a new key and copy it securely
create a new api key

This single API key works for both tools.

How to Use GLM 4.7 with Claude Code

Claude Code is a command-line coding assistant that uses the Anthropic protocol. Z.AI provides a compatible endpoint that maps Claude models to GLM models.

Step 1: Install Claude Code

Claude Code requires Node.js 18 or higher.

npm install -g @anthropic-ai/claude-code
cd your-project
claude

On macOS or Linux, use sudo if permission issues occur. On Windows, run the terminal as an administrator.

install claude code

Step 2: Configure Z.AI for GLM 4.7

Z.AI provides a configuration script that automatically sets the required environment variables.

curl -O "https://cdn.bigmodel.cn/install/claude_code_zai_env.sh" && bash ./claude_code_zai_env.sh

This script updates ~/.claude/settings.json with values similar to:

{
  "env": {
    "ANTHROPIC_AUTH_TOKEN": "your_zai_api_key",
    "ANTHROPIC_BASE_URL": "https://api.z.ai/api/anthropic",
    "API_TIMEOUT_MS": "3000000"
  }
}

By default, Claude Code maps its models as follows:

Claude AliasGLM Model
OpusGLM-4.7
SonnetGLM-4.7
HaikuGLM-4.5-Air

No manual configuration is required for most users.

Step 3: Optional Manual Model Override

If you want explicit control, edit settings.json:

{
  "env": {
    "ANTHROPIC_DEFAULT_OPUS_MODEL": "glm-4.7",
    "ANTHROPIC_DEFAULT_SONNET_MODEL": "glm-4.7",
    "ANTHROPIC_DEFAULT_HAIKU_MODEL": "glm-4.5-air"
  }
}

Restart your terminal after saving changes.

Step 4: Start Coding with GLM 4.7

cd your-project-directory
claude

Grant file access when prompted. You can verify the active model at any time:

/status
claude code status

If configuration changes do not apply, ensure that you're logged out of claude code, then manually edit the settings.json.

How to Use GLM 4.7 with Cursor

Cursor is a desktop-based AI code editor that supports OpenAI-compatible APIs. GLM 4.7 integrates cleanly as a custom provider.

Step 1: Install Cursor

Download and install Cursor from the official website. The setup is straightforward and platform-specific installers are provided.

Step 2: Add GLM 4.7 as a Custom Model

Inside Cursor:

  1. Open Settings → Models
  2. Click Add Custom Model
add a custom model in cursor

3. Choose OpenAI Protocol

4. Enter the following details:

FieldValue
API KeyYour Z.AI API key
Base URLhttps://api.z.ai/api/coding/paas/v4
Model NameGLM-4.7 (uppercase required)

Save the configuration.

create a custom model

Step 3: Switch to GLM 4.7

From Cursor’s model selector, choose your newly added GLM-4.7 provider. No additional setup is required.

Step 4: Start Coding

You can now use GLM 4.7 for:

All within Cursor’s interface.

use glm 4.7 in cursor

Claude Code vs Cursor: Quick Comparison

FeatureClaude CodeCursor
InterfaceTerminal-basedGUI editor
Best ForRepo-level reasoning, scriptingIDE-style development
ProtocolAnthropic-compatibleOpenAI-compatible
GLM 4.7 SupportYesYes
Setup ComplexityMediumLow

Both tools deliver GLM 4.7’s capabilities; the choice depends on personal workflow preference.

Using Apidog Alongside GLM 4.7

As GLM 4.7 helps you write and refactor code, testing remains critical—especially for API-driven systems. Apidog fits naturally into this workflow.

How Apidog Helps

For example, after GLM 4.7 generates a new endpoint, Apidog allows you to immediately test it without writing custom scripts.

{
  "assertions": [
    "statusCode == 200",
    "response.body.success == true"
  ]
}

This combination ensures speed without sacrificing correctness.

button
using custom ai in apidog

Frequently Asked Questions

Q1. Is GLM 4.7 free to use?

GLM 4.7 requires a Z.AI API key. Usage depends on Z.AI’s pricing or free-tier policies.

Q2. Do I need separate API keys for Claude Code and Cursor?

No. A single Z.AI API key works for both tools.

Q3. Can I switch between GLM models?

Yes. Claude Code allows manual overrides, and Cursor supports multiple custom models.

Q4. Does GLM 4.7 replace human code review?

No. It accelerates development, but human review remains essential for correctness and design decisions.

Q5. Is Apidog required to use GLM 4.7?

No, but it is highly recommended for validating API behavior after AI-assisted development.

Conclusion

GLM 4.7, when integrated with Claude Code and Cursor, provides a powerful, flexible approach to AI-assisted development. Claude Code offers deep repository awareness in the terminal, while Cursor delivers an IDE-like experience—both powered by the same advanced model. When combined with API testing tools like Apidog, developers can confidently move from generation to validation without leaving their workflow.

button

Explore more

The Essential API Governance Checklist for US Fintech Teams

The Essential API Governance Checklist for US Fintech Teams

Looking for an API governance checklist for fintech teams in the US? Learn key governance practices for secure, compliant APIs and how Apidog helps enforce API standards, collaboration, and compliance at scale.

26 December 2025

Claude Code is Doubling Limits for Christmas, and Here's My 5 SideProject Ideas to Build

Claude Code is Doubling Limits for Christmas, and Here's My 5 SideProject Ideas to Build

Learn about Claude Code’s doubled holiday usage limits and get 5 practical side project ideas for developers. Includes setup tips, examples, and API testing with Apidog.

26 December 2025

What is Spec-Driven Development (SDD) and How to Implement It?

What is Spec-Driven Development (SDD) and How to Implement It?

Complete guide on Spec-Driven Development (SDD) covering specification-first workflow, core components, tools, and how Apidog automates API validation and testing from specs.

26 December 2025

Practice API Design-first in Apidog

Discover an easier way to build and use APIs