Configure OpenClaw to use Z.AI GLM Coding Plan models for optimal coding performance. Z.AI provides multiple GLM models optimized for development tasks with varying context windows and performance characteristics.
Before configuring Z.AI Coding Plan:
openclaw gateway statusZAI_API_KEY environment variableModel IDContextBest Forglm-5205K tokensLatest flagship, best overall performanceglm-5-turbo200K tokensFast responses, quick iterationsglm-4.7205K tokensBalanced performance, strong reasoningglm-4.7-flash200K tokensQuick iterations, prototypingglm-4.7-flashx200K tokensOptimized speedglm-4.6205K tokensStable, excellent codingglm-4.6v128K tokensVision + coding (UI work)glm-4.5131K tokensEfficient codingglm-4.5-air131K tokensLightweight operationsglm-4.5-flash131K tokensFast coding, cost-effective
bash
openclaw gateway status
Option A: Interactive Setup (Recommended)
International users:
bash
openclaw onboard --auth-choice zai-coding-global
China region users:
bash
openclaw onboard --auth-choice zai-coding-cn
This prompts for the API key and configures everything automatically.
Option B: Manual Configuration
Edit ~/.openclaw/openclaw.json:
json
{
"env": {
"ZAI_API_KEY": "sk-your-api-key-here"
},
"agents": {
"defaults": {
"model": {
"primary": "zai/glm-5"
}
}
}
}
Important: Model format is zai/<model-name>.
For optimal coding performance:
bash
# Enable tool streaming (better for coding workflows)
openclaw config set agents.defaults.models."zai/glm-5".params.tool_stream true --json
# Set higher context for complex projects (optional)
openclaw config set agents.defaults.maxContextTokens 150000
For dedicated coding agents:
bash
openclaw agents create coding-assistant
Configure in ~/.openclaw/openclaw.json:
json
{
"agents": {
"coding-assistant": {
"model": {
"primary": "zai/glm-5"
},
"systemPrompt": "You are an expert software developer. Focus on writing clean, efficient, and well-documented code. Always explain your reasoning and provide best practices.",
"tools": ["filesystem", "shell", "browser"]
}
}
}
bash
# Validate configuration
openclaw config validate
# Restart gateway
openclaw gateway restart
# Check status
openclaw status
Test with a simple coding task:
bash
openclaw chat "Write a Python function to calculate the fibonacci sequence"
Use the right model based on your needs:
zai/glm-5 - Best overall performancezai/glm-5-turbo - Fast responseszai/glm-4.7 - Strong reasoningzai/glm-4.6 - Stable, thoroughzai/glm-4.6v - Vision capabilitieszai/glm-4.5-flash - Cost-effectivezai-coding-global endpoint → https://api.z.ai/api/coding/paas/v4zai-coding-cn endpoint → https://api.bigmodel.cn/api/coding/paas/v4API key missing or invalid:
bash
openclaw config get env.ZAI_API_KEY
Ensure correct endpoint:
bash
# International
https://api.z.ai/api/coding/paas/v4
# China
https://api.bigmodel.cn/api/coding/paas/v4
GLM Coding Plan has usage limits based on subscription tier:
bash
# Check logs
openclaw gateway logs
# Validate config
openclaw config validate
# Reset if needed
openclaw config reset
To change the default model:
bash
# Set new model
openclaw config set agents.defaults.model.primary "zai/glm-4.7"
# Restart to apply
openclaw gateway restart
This configuration works with all OpenClaw channels:
openclaw chatCommandDescriptionopenclaw config get agents.defaults.modelCheck current modelopenclaw config set agents.defaults.model.primary "zai/glm-5"Change modelopenclaw gateway restartApply changesopenclaw statusVerify configuration
GLM Coding Plan includes powerful MCP tools for web access and code research. These tools are exclusive to Coding Plan subscribers.
ToolDescriptionUse CaseWeb SearchSearch the web for real-time informationFinding documentation, news, tutorialsWeb ReaderExtract full content from any webpageReading articles, docs, extracting dataZreadAccess GitHub repositories documentation & codeUnderstanding open-source projects
PlanWeb Searches + Readers + ZreadLite100 totalPro1,000 totalMax4,000 total
After configuring the model, add the MCP tools to enhance your coding agent.
web-search-prime)Provides real-time web search capabilities.
One-click install (OpenClaw):
bash
openclaw mcp add web-search-prime --type http --url "https://api.z.ai/api/mcp/web_search_prime/mcp" --header "Authorization: Bearer YOUR_API_KEY"
Manual configuration - Add to ~/.openclaw/openclaw.json:
json
{
"mcpServers": {
"web-search-prime": {
"type": "http",
"url": "https://api.z.ai/api/mcp/web_search_prime/mcp",
"headers": {
"Authorization": "Bearer YOUR_API_KEY"
}
}
}
}
Available tool: webSearchPrime - Search web information with titles, URLs, summaries
web-reader)Extracts complete content from any webpage.
One-click install (OpenClaw):
bash
openclaw mcp add web-reader --type http --url "https://api.z.ai/api/mcp/web_reader/mcp" --header "Authorization: Bearer YOUR_API_KEY"
Manual configuration - Add to ~/.openclaw/openclaw.json:
json
{
"mcpServers": {
"web-reader": {
"type": "http",
"url": "https://api.z.ai/api/mcp/web_reader/mcp",
"headers": {
"Authorization": "Bearer YOUR_API_KEY"
}
}
}
}
Available tool: webReader - Fetch page title, main content, metadata, links
zread)Access GitHub repositories for documentation and code analysis.
One-click install (OpenClaw):
bash
openclaw mcp add zread --type http --url "https://api.z.ai/api/mcp/zread/mcp" --header "Authorization: Bearer YOUR_API_KEY"
Manual configuration - Add to ~/.openclaw/openclaw.json:
json
{
"mcpServers": {
"zread": {
"type": "http",
"url": "https://api.z.ai/api/mcp/zread/mcp",
"headers": {
"Authorization": "Bearer YOUR_API_KEY"
}
}
}
}
Available tools:
ToolDescriptionsearch_docSearch documentation in GitHub repositoriesget_repo_structureGet directory structure and file listread_fileRead complete code content of files
Here's a complete ~/.openclaw/openclaw.json with all three MCP tools:
json
{
"env": {
"ZAI_API_KEY": "sk-your-api-key-here"
},
"agents": {
"defaults": {
"model": {
"primary": "zai/glm-5"
}
}
},
"mcpServers": {
"web-search-prime": {
"type": "http",
"url": "https://api.z.ai/api/mcp/web_search_prime/mcp",
"headers": {
"Authorization": "Bearer sk-your-api-key-here"
}
},
"web-reader": {
"type": "http",
"url": "https://api.z.ai/api/mcp/web_reader/mcp",
"headers": {
"Authorization": "Bearer sk-your-api-key-here"
}
},
"zread": {
"type": "http",
"url": "https://api.z.ai/api/mcp/zread/mcp",
"headers": {
"Authorization": "Bearer sk-your-api-key-here"
}
}
}
}
After adding the MCP tools, restart and verify:
bash
# Restart gateway to load MCP servers
openclaw gateway restart
# Check MCP status
openclaw mcp list
# Verify tools are available
openclaw status
Test each tool to ensure proper configuration:
Test Web Search:
bash
openclaw chat "Search for the latest Python 3.12 features"
Test Web Reader:
bash
openclaw chat "Read and summarize the content from https://docs.python.org/3/whatsnew/3.12.html"
Test Zread:
bash
openclaw chat "Explain the structure of the fastapi/fastapi repository on GitHub"
text
Error: Invalid access token
Solutions:
Authorization: Bearer format is correctSolutions:
Solutions:
owner/repotext
Error: Rate limit exceeded
Solution: Wait for the next 5-hour cycle or upgrade your plan
ScenarioTools to UseExample PromptResearch a libraryZread + Web Search"Research the React hooks API and find best practices"Debug an issueWeb Search + Web Reader"Search for solutions to 'Python asyncio CancelledError'"Learn a new frameworkZread"Explain the architecture of the Next.js repository"Stay updatedWeb Search"What are the latest updates in TypeScript 5.4?"Read documentationWeb Reader"Read the FastAPI authentication documentation"