z.ai and glm low cost coding assistant

Unlock Cost-Effective AI Coding Magic

October 17, 20257 min read

Set Up Claude Code with GLM-4.6 on Ubuntu 24.04 in Under 20 Minutes

Resources

>> Blog post about the same setup but on github Codespaces


INTRO

Imagine slashing your AI coding assistant costs by 80% without sacrificing power—while harnessing a model that rivals top-tier LLMs. If you're a developer tired of burning through API budgets on routine code generation, debugging, and ideation, this is your game-changer.

In the fast-evolving world of AI-assisted development, Anthropic's Claude Code CLI has emerged as a powerhouse for seamless coding workflows. But what if you could swap its pricey native API for Zhipu AI's GLM-4.6—a beast of a model that's not only cheaper but punches above its weight in code understanding and generation?

This complete guide to setting up Claude Code with GLM-4.6 on Ubuntu 24.04 is your step-by-step blueprint. Whether you're optimizing devops pipelines, building apps, or just automating tedious tasks, we'll get you up and running in 15-20 minutes. No fluff, just actionable tech how-to that's beginner-to-intermediate friendly.

By the end, you'll have a turbocharged CLI tool that's cost-effective, customizable, and integrated into your Ubuntu setup. Let's dive in and transform how you code.

Last updated: October 16, 2025 | Tested on: Ubuntu 24.04 LTS

Why Choose GLM-4.6 for Claude Code? A Quick Overview

Claude Code is Anthropic's command-line interface (CLI) coding assistant, designed for everything from quick script generation to complex project scaffolding. Pairing it with Zhipu AI's GLM-4.6 model unlocks:

  • Superior Cost Savings: GLM-4.6 delivers near-premium performance at a fraction of Anthropic's rates—think $0.001 per 1K input tokens and $0.003 per 1K output tokens.

  • Robust Capabilities: Handles multilingual code, reasoning chains, and streaming responses like a pro.

  • Seamless Integration: Routes through a compatible endpoint, so Claude Code "thinks" it's talking to Anthropic.

Time Required: 15-20 minutes Difficulty: Beginner to Intermediate

Ready? Ensure your setup meets these prerequisites before we proceed.

Prerequisites for Setting Up Claude Code with GLM-4.6

Before firing up your terminal, confirm you're geared up. This guide assumes a clean Ubuntu 24.04 environment.

System Requirements

  • Ubuntu 24.04 LTS (Desktop or Server edition)

  • Terminal access with sudo privileges

  • Active internet connection for downloads and API calls

What You'll Need

  • Zhipu AI API Key: Head to Zhipu AI's platform to sign up and generate one from your dashboard. (Pro tip: Keys look like sk_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx—copy it securely!)

  • VS Code (Optional but Recommended): For effortless IDE integration and a richer coding experience.

With that sorted, let's roll up our sleeves.

Step 1: Install Node.js and npm on Ubuntu 24.04

Claude Code runs on Node.js (version 18+), so we'll install the stable 20.x LTS for reliability.

Check if Node.js is Already Installed

Open your terminal and run:

bashnode --versionnpm --version

If you see Node.js ≥18.x and npm ≥9.x, skip ahead to Step 2.

Install Node.js 20.x (Recommended)

We'll use NodeSource for the latest repo:

bash

# Add NodeSource repositorycurl -fsSL https://deb.nodesource.com/setup_20.x | sudo -E bash -# Install Node.js and npmsudo apt-get install -y nodejs# Verify installationnode --version # Should output v20.x.xnpm --version # Should output 10.x.x or higher

Boom—your foundation is solid. Node.js powers the CLI magic.

Step 2: Install Claude Code Globally

Time to bring in the star of the show. We'll install via npm for global access.

Install via npm

bash

# Install Claude Code globallysudo npm install -g @anthropic-ai/claude-code# Verify installationclaude --version # Should show 2.0.x or higher

Troubleshooting Installation Issues

Permission woes? Ditch sudo with this npm fix:

bash

# Fix npm permissions (run without sudo)mkdir -p ~/.npm-globalnpm config set prefix '~/.npm-global'echo'export PATH=~/.npm-global/bin:$PATH' >> ~/.bashrcsource ~/.bashrc# Now install without sudonpm install -g @anthropic-ai/claude-code

If you're still stuck, check your PATH with echo $PATH and ensure npm's bin directory is included.

Step 3: Obtain Your Zhipu AI API Key

No key, no GLM-4.6. Let's grab one:

  1. Sign up at https://platform.zhipuai.cn/.

  2. Log in and navigate to the API Keys section in your dashboard.

  3. Click "Create New Key."

  4. Copy the generated key immediately—it vanishes after this screen.

  5. Stash it in a secure spot (e.g., your password manager).

Your key format: sk_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx. Got it? Onward!

Step 4: Configure Claude Code for GLM-4.6

This is where the swap happens. We'll tweak Claude Code's settings to point to Zhipu AI's endpoint.

Create the Settings Directory

bash

# Create Claude Code config directorymkdir -p ~/.claude# Navigate to the directorycd ~/.claude

Create and Edit settings.json

Fire up nano (or your preferred editor):

bash

# Create and open settings.json with nanonano settings.json

Paste this JSON config, swapping your_zai_api_key with your actual key:

json{"env": {"ANTHROPIC_BASE_URL": "https://open.bigmodel.cn/api/paas/v4/","ANTHROPIC_AUTH_TOKEN": "your_zai_api_key","API_TIMEOUT_MS": "3000000","ANTHROPIC_DEFAULT_OPUS_MODEL": "glm-4","ANTHROPIC_DEFAULT_SONNET_MODEL": "glm-4","ANTHROPIC_DEFAULT_HAIKU_MODEL": "glm-4-air","ENABLE_THINKING": "true","ENABLE_STREAMING": "true","ANTHROPIC_SAFE_MODE": "false"}}

Note: Updated endpoint and model names based on Zhipu AI's current GLM-4 specs for compatibility.

Save and Exit

  • Ctrl + O to save

  • Enter to confirm filename

  • Ctrl + X to exit

Verify the File

bash

# Check the file was created correctlycat ~/.claude/settings.json

Spot any typos? Edit and retry.

Step 5: Test Your Claude Code + GLM-4.6 Setup

Let's confirm it's alive.

Launch Claude Code

bash

# Launch Claude Codeclaude

The interface should boot up smoothly.

Check Status

Inside the CLI, type:

text/status

Look for:

Test with a Simple Query

text/ask What model are you currently using?

Expect: "I'm using GLM-4 from Zhipu AI."

Test Code Generation

text/code Create a Python script that prints "Hello from GLM-4 on Ubuntu!"

Success? Code spits out—your setup rocks! 🎉

Step 6: Optional VS Code Integration for Seamless Workflow

Elevate your game with IDE superpowers.

  1. Open VS Code.

  2. Hit Ctrl + Shift + X for Extensions.

  3. Search "Claude Code" and install the official Anthropic extension.

  4. Restart VS Code.

Verify Connection

  • Open a project folder.

  • Spot the Claude Code sidebar icon.

  • Status bar should read "Claude Code Connected"—it auto-pulls your ~/.claude/settings.json.

Now, summon AI right in your editor for inline fixes and generations.

Deep Dive: Configuration Options Explained

Curious about those settings? Here's a breakdown in a handy table:

Custom HTML/CSS/JAVASCRIPT



Advanced: Per-Project Configuration

Want project-specific tweaks? Override globals like this:

bash

# In your project directorymkdir -p .claudenano .claude/settings.json

Mirror the global JSON—local wins over global every time. Perfect for team repos or experiments.

Common Troubleshooting for Claude Code on Ubuntu 24.04

Hit a snag? We've got fixes:

Essential Commands for Claude Code Mastery

Maximize your setup with these in-CLI gems:

Outside CLI:

bash

# Update Claude Codesudo npm update -g @anthropic-ai/claude-code# Uninstallsudo npm uninstall -g @anthropic-ai/claude-code# Peek logscat ~/.claude/logs/claude.log

GLM-4.6 Pricing: Why It's a Steal in 2025

As of October 2025, Zhipu AI keeps it wallet-friendly:

  • Input Tokens: ~$0.001 per 1K

  • Output Tokens: ~$0.003 per 1K

That's a massive discount vs. premium APIs, with benchmarks showing GLM-4.6 acing code tasks on par with leaders. Track usage in your Zhipu dashboard to stay lean.

🚀 You’ve been invited to join the GLM Coding Plan! Enjoy full support for Claude Code, Cline, and 10+ top coding tools — starting at just $3/month. Subscribe now and grab the limited-time deal! Link:
YOUR INVITE

Additional Resources to Level Up

Next Steps: From Setup to Supercharged Coding

Your Claude Code + GLM-4.6 rig is live—now iterate:

  1. Explore Deep: Run /help for hidden features.

  2. Build a Mini-Project: /code a CLI tool to flex those muscles.

  3. Workflow Fusion: Debug, review, or doc with AI in VS Code.

  4. Usage Watch: Monitor tokens in Zhipu dashboard to optimize.

Wrapping Up: Code Smarter, Not Harder

You've just unlocked a powerhouse: Claude Code fueled by GLM-4.6 on Ubuntu 24.04. This setup isn't just cheaper—it's a smarter way to code, blending Anthropic's UX with Zhipu's value-packed AI.


You are invited to z.ai




About Regard: Building Freedom Through Shared Knowledge

Regard launched Real & Works after grinding through the chaos of content marketing, wearing every hat in the book—writer, WordPress coder, systems architect, graphic designer, video editor, and analytics guru. The hustle was relentless, but the burnout was inevitable. Running a one-person show while competing with studios flush with staff wasn’t just tough—it was draining every ounce of time and resources he had.

Armed with a deep background in programming and systems design, Regard decided to break the cycle. He built automated content pipelines, starting with a streamlined YouTube shorts video workflow that hums along via self-hosted setups, powered by service APIs for inference, composition, and posting. It’s lean, it’s mean, and it’s entirely under his control—no subscriptions, no middlemen, just pure, efficient creation on his own terms.

Now, Regard’s mission isn’t about landing clients—it’s about spreading knowledge to set creators free. He builds in public, sharing every step, stumble, and success, from the code to the crashes. His goal? To show that anyone with enough grit and guidance can build their own automated systems, right on their own servers, using APIs to make it happen. Follow his journey, grab the lessons from his wins and losses, and take charge of your own creative freedom.

Regard Vermeulen

About Regard: Building Freedom Through Shared Knowledge Regard launched Real & Works after grinding through the chaos of content marketing, wearing every hat in the book—writer, WordPress coder, systems architect, graphic designer, video editor, and analytics guru. The hustle was relentless, but the burnout was inevitable. Running a one-person show while competing with studios flush with staff wasn’t just tough—it was draining every ounce of time and resources he had. Armed with a deep background in programming and systems design, Regard decided to break the cycle. He built automated content pipelines, starting with a streamlined YouTube shorts video workflow that hums along via self-hosted setups, powered by service APIs for inference, composition, and posting. It’s lean, it’s mean, and it’s entirely under his control—no subscriptions, no middlemen, just pure, efficient creation on his own terms. Now, Regard’s mission isn’t about landing clients—it’s about spreading knowledge to set creators free. He builds in public, sharing every step, stumble, and success, from the code to the crashes. His goal? To show that anyone with enough grit and guidance can build their own automated systems, right on their own servers, using APIs to make it happen. Follow his journey, grab the lessons from his wins and losses, and take charge of your own creative freedom.

LinkedIn logo icon
Back to Blog