Introduction
Are you looking to supercharge your Hetzner server for cutting-edge AI development? Setting up GLM 4.7 (the latest Chinese large language model from Zhipu AI) within Claude Code on Hetzner gives you an incredible advantage in the AI development space.
This comprehensive guide walks you through the entire setup process, from SSH access to testing your first GLM 4.7 integration, with all the commands, tips, and troubleshooting steps you need.
Why This Setup Matters
GLM 4.7 brings massive improvements over previous models:
- 128k context window vs 32k in GPT-3.5 Turbo
- Superior coding capabilities with better reasoning
- Faster inference with optimized architecture
- Multilingual understanding - perfect for diverse projects
- Cost-efficient competitive performance at lower cost
When combined with Claude Code:
- Intelligent code editing and generation
- Context-aware suggestions across your entire project
- Built-in terminal for direct server access
- File system integration for seamless code management
This setup gives you an enterprise-grade AI development environment at a fraction of the cost of alternatives.
Table of Contents
1. Prerequisites
Before you begin, ensure you have:
- Hetzner account with active subscription
- Server deployed (Cloud Panel, VPS, or dedicated)
- SSH access credentials (password or SSH key)
- GLM 4.7 API key from Zhipu AI
- Node.js 18+ installed locally (for verification)
If you're using Hetzner's NixOS images, Claude Code may already be pre-installed! Check the installation options section below.
2. SSH Access to Hetzner
Basic SSH Connection
# SSH into your Hetzner server
ssh root@your-server-ip
# Example with actual Hetzner format
ssh root@123.45.67.89
SSH Keys (Recommended)
# Generate SSH key pair (one-time setup)
ssh-keygen -t rsa -b 4096 -f ~/.ssh/hetzner_key
# Copy public key to Hetzner (via their console)
cat ~/.ssh/hetzner_key.pub
# Add to Hetzner server in their dashboard
# Settings → SSH Keys → Add SSH Key
# Then connect with the key
ssh -i ~/.ssh/hetzner_key root@your-server-ip
Using tmux for Persistent Sessions
# Create named tmux session for AI development
tmux new -s ai-dev
# Now you can disconnect and reconnect anytime
# Press Ctrl+B, then D to detach
# Reattach with: tmux attach -t ai-dev
- Keeps your SSH session alive even if you close your laptop
- Multiple terminal panes for different tasks
- Ideal for running long AI training or builds
3. Set Up Claude Code
Check for Pre-Installed Claude Code
If you're using Hetzner's NixOS or their VPS images with Claude Code pre-installed:
# SSH into your server
ssh root@your-server-ip
# Check if Claude Code is already running
ps aux | grep claude-code
# Check if Claude Code is accessible
curl -I http://localhost:3000
# If both work - you're done! Skip to next section
Manual Setup (Ubuntu/Debian)
Step 1: Update System & Install Node.js
# Update package lists
apt update && apt upgrade -y
# Install Node.js 20+ (required for Claude Code)
curl -fsSL https://deb.nodesource.com/setup_20.x | bash -
apt install -y nodejs
# Verify Node.js version (should be v20+)
node --version
Step 2: Install Git
# Install Git for cloning Claude Code repository
apt install -y git
Step 3: Clone or Update Claude Code
# Navigate to your project directory
cd /root
# Clone Claude Code (if not already present)
git clone https://github.com/anthropics/claude-code.git
cd claude-code
# OR if already exists
cd /root/claude-code
git pull
Step 4: Install Dependencies
# Navigate to Claude Code directory
cd /root/claude-code
# Install all dependencies
npm install
Step 5: Build Claude Code
# Build the application
npm run build
Step 6: Install as Systemd Service
Create a systemd service file for auto-restart:
# Create service file
sudo nano /etc/systemd/system/claude-code.service
Add this content:
[Unit]
Description=Claude Code - AI Development Environment
After=network.target
[Service]
Type=simple
User=root
WorkingDirectory=/root/claude-code
ExecStart=/usr/bin/npm start
Restart=always
RestartSec=10
[Install]
WantedBy=multi-user.target
Step 7: Enable and Start Service
# Reload systemd to recognize new service
sudo systemctl daemon-reload
# Enable Claude Code to start on boot
sudo systemctl enable claude-code
# Start Claude Code immediately
sudo systemctl start claude-code
# Check service status
sudo systemctl status claude-code
4. Configure GLM 4.7
Getting Your GLM API Key
GLM 4.7 is accessible through Zhipu AI:
- Website: https://open.bigmodel.cn/
- Sign up for free tier
- Get API key from dashboard
- Free tier: 1M tokens/month (good for testing)
Configuring GLM in Claude Code
Via Environment Variables (Easiest)
# SSH into your server
ssh root@your-server-ip
# Set GLM API key as environment variable
export GLM_API_KEY="your-glm-api-key-here"
Verify GLM Configuration
# Restart Claude Code to pick up new config
sudo systemctl restart claude-code
# Check logs for GLM initialization
sudo journalctl -u claude-code -f | grep -i glm
5. Integration Guide
Using GLM 4.7 in Claude Code
Once configured, GLM 4.7 seamlessly integrates with Claude Code:
Features Available:
- Code Completion - GLM 4.7 suggests code snippets
- Context-Aware Chat - Maintains conversation across your project
- Code Explanation - Explains complex functions
- Multi-Language Support - Perfect for international teams
- Built-in Terminal - Execute commands directly in Claude Code
6. Testing & Verification
Test 1: Verify Claude Code is Running
# Check Claude Code process
ps aux | grep claude-code
# Check if accessible on port 3000
curl -I http://localhost:3000
Test 2: API Call Verification
# Quick GLM 4.7 API test
curl -X POST https://open.bigmodel.cn/api/paas/v4/chat/completions \
-H "Authorization: Bearer YOUR_GLM_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "glm-4-flash",
"messages": [
{"role": "user", "content": "Hello GLM 4.7!"}
]
}'
- Claude Code running (port 3000)
- GLM 4.7 API key configured
- Claude Code web UI accessible
- Test API call successful
7. Common Issues & Solutions
Issue 1: GLM 4.7 API Returns 401 Unauthorized
Symptoms:
- Claude Code shows GLM 4.7 but won't use it
- API calls in logs show 401 errors
Solutions:
# Verify your API key is correct
echo $GLM_API_KEY | head -c 20
# Test with curl directly
curl -X POST https://open.bigmodel.cn/api/paas/v4/chat/completions \
-H "Authorization: Bearer YOUR_ACTUAL_KEY" \
-H "Content-Type: application/json" \
-d '{"model":"glm-4-flash","messages":[{"role":"user","content":"test"}]}'
Issue 2: Claude Code Won't Start
# Check Node.js version (must be 18+)
node --version
# Check if port 3000 is already in use
lsof -i :3000
# Try manual start
cd /root/claude-code
npm start
| Problem | Solution |
|---|---|
| GLM not showing | Check npm list, restart Claude Code |
| 401 API errors | Verify API key in environment variable |
| Slow responses | Check network speed, reduce maxTokens |
| Connection refused | Check firewall in Hetzner console |
| Service won't start | Check Node.js version, look at logs |
Conclusion
Setting up GLM 4.7 with Claude Code on Hetzner gives you a powerful, cost-effective AI development environment:
- 128k context - Handle entire projects at once
- Chinese LLM - Access to latest language models
- Integrated workflow - Seamless Claude Code + GLM 4.7
- Built-in terminal - No external SSH needed
- Fast inference - Optimized for rapid iteration
- Cost efficient - Competitive to enterprise alternatives
- Enterprise-grade AI development environment
- Full-stack capabilities with advanced LLM
- Ready for cutting-edge applications
- Extensible architecture for future growth
Need Help?
Resources
- Claude Code Documentation: https://docs.anthropic.com/claude-code/
- GLM 4.7 API Docs: https://open.bigmodel.cn/dev/api
- Hetzner Documentation: https://docs.hetzner.com/
Last Updated: January 11, 2026 | Version: 1.0