plugins/zai-glm/skills/zai-setup/SKILL.md
Use this skill when the user asks about z.ai, Zhipu AI, setting up z.ai API access, getting a z.ai API key, configuring Claude Code to use z.ai models directly via the Anthropic-compatible endpoint, routing z.ai through Cloudflare AI Gateway or OpenRouter, or using z.ai's OpenAI-compatible API.
npx skillsauth add nsheaps/ai-mktpl zai-setupInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
z.ai (formerly Zhipu AI / 智谱AI, rebranded July 2025) is a Chinese AI company that develops the GLM (General Language Model) family. They provide both OpenAI-compatible and Anthropic-compatible API endpoints.
https://api.z.ai/api/paas/v4/https://open.bigmodel.cn/api/paas/v4/https://api.z.ai/api/anthropicz.ai provides two compatible API formats:
curl "https://api.z.ai/api/paas/v4/chat/completions" \
-H "Authorization: Bearer YOUR_ZHIPU_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "glm-4.7",
"messages": [{"role": "user", "content": "Hello!"}]
}'
from openai import OpenAI
client = OpenAI(
api_key="YOUR_ZHIPU_API_KEY",
base_url="https://api.z.ai/api/paas/v4/"
)
response = client.chat.completions.create(
model="glm-4.7",
messages=[{"role": "user", "content": "Hello!"}]
)
import OpenAI from "openai";
const client = new OpenAI({
apiKey: "YOUR_ZHIPU_API_KEY",
baseURL: "https://api.z.ai/api/paas/v4/",
});
const response = await client.chat.completions.create({
model: "glm-4.7",
messages: [{ role: "user", content: "Hello!" }],
});
z.ai also provides an endpoint that speaks the Anthropic Messages API protocol. This is what enables direct Claude Code integration.
z.ai provides a native Anthropic-compatible endpoint at https://api.z.ai/api/anthropic. Claude Code can connect directly — no proxy needed.
In ~/.claude/settings.json:
{
"env": {
"ANTHROPIC_BASE_URL": "https://api.z.ai/api/anthropic",
"ANTHROPIC_AUTH_TOKEN": "your-zai-api-key",
"CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC": "1"
}
}
Or via shell alias:
# Add to ~/.bashrc or ~/.zshrc
zaiclaude() {
ANTHROPIC_BASE_URL=https://api.z.ai/api/anthropic \
ANTHROPIC_AUTH_TOKEN="your-zai-api-key" \
CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC=1 \
claude "$@"
}
Optional model mapping — map Claude Code's model slots to specific GLM models:
{
"env": {
"ANTHROPIC_BASE_URL": "https://api.z.ai/api/anthropic",
"ANTHROPIC_AUTH_TOKEN": "your-zai-api-key",
"ANTHROPIC_DEFAULT_HAIKU_MODEL": "glm-4.5-air",
"ANTHROPIC_DEFAULT_SONNET_MODEL": "glm-4.7",
"ANTHROPIC_DEFAULT_OPUS_MODEL": "glm-5",
"CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC": "1"
}
}
| Variable | Purpose |
| ------------------------------------------ | ---------------------------------------------------------- |
| ANTHROPIC_BASE_URL | Points Claude Code to z.ai's Anthropic endpoint |
| ANTHROPIC_AUTH_TOKEN | Your z.ai API key |
| ANTHROPIC_API_KEY | Set to "" to avoid conflicts with existing Anthropic key |
| CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC | Prevents background traffic to Anthropic servers |
| ANTHROPIC_DEFAULT_SONNET_MODEL | GLM model for the "Sonnet" slot |
| ANTHROPIC_DEFAULT_OPUS_MODEL | GLM model for the "Opus" slot |
| ANTHROPIC_DEFAULT_HAIKU_MODEL | GLM model for the "Haiku" slot |
Note: See https://docs.z.ai/scenario-example/develop-tools/claude for z.ai's official Claude Code integration guide.
Route z.ai through Cloudflare AI Gateway for logging, caching, and cost tracking. See the cloudflare-ai-gateway skill for full setup.
# Use the universal endpoint to proxy z.ai through your gateway
curl "https://gateway.ai.cloudflare.com/v1/ACCT_ID/GATEWAY_ID" \
-H "Content-Type: application/json" \
-d '[{
"provider": "zhipu",
"endpoint": "https://api.z.ai/api/paas/v4/chat/completions",
"headers": { "Authorization": "Bearer YOUR_ZHIPU_API_KEY" },
"query": {
"model": "glm-4.7",
"messages": [{"role": "user", "content": "Hello"}]
}
}]'
OpenRouter aggregates many model providers including z.ai/Zhipu models:
curl "https://openrouter.ai/api/v1/chat/completions" \
-H "Authorization: Bearer $OPENROUTER_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "zhipu/glm-4.7",
"messages": [{"role": "user", "content": "Hello"}]
}'
For Claude Code web sessions, set environment variables in .claude/settings.local.json (gitignored):
{
"env": {
"ANTHROPIC_BASE_URL": "https://api.z.ai/api/anthropic",
"ANTHROPIC_AUTH_TOKEN": "your-zai-api-key",
"CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC": "1"
}
}
Important: Never put API keys in
settings.json(committed). Always usesettings.local.json(gitignored) or a secrets manager like 1Password. These use the same Anthropic-compatible environment variables as Option 1 above.
z.ai offers a Coding Plan subscription for enhanced coding model access:
https://api.z.ai/api/coding/paas/v4tools
Manually reproduce what the github-app plugin's SessionStart hook does to make a GitHub App installation token usable in the current session — materialize the PEM, generate the token, isolate GH_CONFIG_DIR, write the runtime env file, and wire CLAUDE_ENV_FILE so every Bash call sees GH_TOKEN/GITHUB_TOKEN. Use when the hook did not run, the token is missing from the environment, or a shell/teammate needs the token wired up by hand. <example>GH_TOKEN isn't set even though github-app is configured</example> <example>the github-app SessionStart hook didn't run, set up the token manually</example> <example>wire the github app token into CLAUDE_ENV_FILE</example> <example>gh keeps falling back to the wrong account, isolate GH_CONFIG_DIR</example>
tools
Manually configure the GitHub App bot git identity the way the github-app plugin's SessionStart hook does — resolve the app slug and bot user ID, build the <slug>[bot] name and noreply email, set GIT_AUTHOR_*/GIT_COMMITTER_* env vars, and write an isolated GIT_CONFIG_GLOBAL with the gh auth git-credential helper. Use when commits are attributed to the wrong account, "Author identity unknown" appears, or git identity must be set up by hand. <example>my commits are showing up as the handler, not the bot</example> <example>git says Author identity unknown after the github-app hook ran</example> <example>configure the github app bot git identity manually</example> <example>set up the gh credential helper for git push</example>
tools
Manages spec files for requirements capture and validation
tools
# Bash Chaining Alternatives This skill teaches you how to work around the bash command chaining restriction enforced by this plugin. ## Why Chaining is Blocked The `bash-command-rejection` plugin blocks these operators: | Operator | Name | Why Blocked | | -------- | ---------- | ----------------------------------------------------------------------------------- | | `&&` | AND chain | Runs cmd2 only if cmd1 su