Configure Z.ai for Claude Code and Codex

Use these files to run Z.ai GLM models in Claude Code or Codex. The JSON and TOML formats are not interchangeable.

.claude/settings-zai.json
{
  "$schema": "https://json.schemastore.org/claude-code-settings.json",
  "promptCacheTtl": "1h",
  "env": {
    "ANTHROPIC_AUTH_TOKEN": "your_zai_api_key",
    "ANTHROPIC_BASE_URL": "https://api.z.ai/api/anthropic",
    "API_TIMEOUT_MS": "3000000",
    "CLAUDE_BASH_MAINTAIN_PROJECT_WORKING_DIR": "1",
    "DISABLE_BUG_COMMAND": "1",
    "DISABLE_ERROR_REPORTING": "1",
    "CLAUDE_CODE_DISABLE_FEEDBACK_SURVEY": "1",
    "ANTHROPIC_DEFAULT_OPUS_MODEL": "glm-5.3[1m]",
    "ANTHROPIC_DEFAULT_SONNET_MODEL": "glm-5.3[1m]",
    "ANTHROPIC_DEFAULT_HAIKU_MODEL": "glm-5.3-flash",
    "ANTHROPIC_DEFAULT_FABLE_MODEL": "glm-5.3[1m]",
    "MAX_MCP_OUTPUT_TOKENS": "40000",
    "CLAUDE_CODE_AUTO_COMPACT_WINDOW": "500000",
    "CLAUDE_CODE_EXPERIMENTAL_AGENT_TEAMS": "1",
    "CLAUDE_CODE_DISABLE_OFFICIAL_MARKETPLACE_AUTOINSTALL": "1",
    "CLAUDE_CODE_ENABLE_FINE_GRAINED_TOOL_STREAMING": "1",
    "CLAUDE_CODE_NEW_INIT": "1",
    "CLAUDE_CODE_NO_FLICKER": "1",
    "SLASH_COMMAND_TOOL_CHAR_BUDGET": "60000"
  },
  "attribution": {
    "commit": "",
    "pr": "",
    "sessionUrl": false
  },
  "permissions": {
    "defaultMode": "default",
    "allow": [
      "Bash(find:*)",
      "Bash(rg:*)",
      "Bash(echo:*)",
      "Bash(grep:*)",
      "Bash(ls:*)",
      "Bash(wc:*)",
      "Bash(cat:*)",
      "Bash(sed:*)",
      "Bash(tree:*)",
      "Bash(tail:*)",
      "Bash(pgrep:*)",
      "Bash(ps:*)",
      "Bash(sort:*)",
      "Bash(dmesg:*)",
      "Bash(done)",
      "Bash(ruff:*)",
      "Bash(nvidia-smi:*)",
      "Bash(pdflatex:*)",
      "Bash(biber:*)",
      "Bash(tmux ls:*)",
      "Bash(tmux capture-pane:*)",
      "Bash(tmux list-sessions:*)",
      "Bash(tmux list-windows:*)",
      "Bash(tmux has-session:*)",
      "Bash(tmux new-session:*)",
      "Bash(gh pr list:*)",
      "Bash(gh pr view:*)",
      "Bash(gh pr diff:*)",
      "Bash(gh api user:*)",
      "Bash(gh repo view:*)",
      "Bash(gh issue view:*)",
      "Bash(gh search:*)",
      "Bash(git branch --show-current:*)",
      "Bash(git diff:*)",
      "Bash(git status:*)",
      "Bash(git rev-parse:*)",
      "Bash(git push:*)",
      "Bash(git log:*)",
      "Bash(git -C :* branch --show-current:*)",
      "Bash(git -C :* diff:*)",
      "Bash(git -C :* status:*)",
      "Bash(git -C :* rev-parse:*)",
      "Bash(git -C :* push:*)",
      "Bash(git -C :* log:*)",
      "Bash(git fetch --prune:*)",
      "Bash(git worktree list:*)",
      "Bash(git show:*)",
      "Bash(uv run ruff:*)",
      "Bash(python --version:*)",
      "Bash(python -c:*)",
      "Bash(python3 -c:*)",
      "Bash(python -m json.tool:*)",
      "Bash(sleep:*)",
      "Bash(source .venv/bin/activate:*)",
      "Bash(mkdir -p:*)",
      "WebSearch",
      "WebFetch(domain:openai.com)",
      "WebFetch(domain:anthropic.com)",
      "WebFetch(domain:docs.anthropic.com)",
      "WebFetch(domain:ai.google.dev)",
      "WebFetch(domain:github.com)",
      "WebFetch(domain:gradio.app)",
      "WebFetch(domain:arxiv.org)",
      "WebFetch(domain:dl.acm.org)",
      "WebFetch(domain:openaccess.thecvf.com)",
      "WebFetch(domain:www.semanticscholar.org)",
      "WebFetch(domain:openreview.net)",
      "WebFetch(domain:doi.org)",
      "WebFetch(domain:link.springer.com)",
      "WebFetch(domain:pypi.org)",
      "WebFetch(domain:docs.ultralytics.com)",
      "WebFetch(domain:sli.dev)",
      "WebFetch(domain:docs.vllm.ai)",
      "WebFetch(domain:developer.themoviedb.org)",
      "mcp__tavily__tavily_extract",
      "mcp__tavily__tavily_search",
      "mcp__context7__resolve-library-id",
      "mcp__context7__get-library-docs",
      "mcp__github__get_me",
      "mcp__github__pull_request_read",
      "mcp__github__get_file_contents",
      "mcp__github__get_workflow_run",
      "mcp__github__get_job_logs",
      "mcp__github__get_pull_request_comments",
      "mcp__github__get_pull_request_reviews",
      "mcp__github__issue_read",
      "mcp__github__list_pull_requests",
      "mcp__github__list_commits",
      "mcp__github__list_workflows",
      "mcp__github__list_workflow_runs",
      "mcp__github__list_workflow_jobs",
      "mcp__github__search_pull_requests",
      "mcp__github__search_issues",
      "mcp__github__search_code",
      "mcp__wandb__query_wandb_tool",
      "mcp__wandb__query_wandb_entity_projects",
      "mcp__mongodb__list_databases",
      "mcp__mongodb__list_collections",
      "mcp__mongodb__get_collection_schema",
      "mcp__mongodb__collection-indexes",
      "mcp__mongodb__db-stats",
      "mcp__mongodb__count",
      "mcp__supabase__list_tables",
      "mcp__gcloud-observability__list_log_entries"
    ]
  },
  "hooks": {
    "PreToolUse": [
      {
        "matcher": "Bash",
        "hooks": [
          {
            "type": "command",
            "command": "bash -c 'CMD=$(jq -r \".tool_input.command\"); if ! echo \"$CMD\" | rg -qP \"(\\brm\\s+-|\\brm\\s+/|\\brmdir\\b|shutil\\.rmtree|os\\.remove|os\\.unlink|\\bsubprocess\\b|os\\.system|\\bopen\\(.*[\\x27\\\"]w|\\bcurl\\s|\\bwget\\s|\\bpip\\s+install|\\bkill\\s|\\bpkill\\b|\\bchmod\\b|\\bchown\\b|\\bmv\\s+|\\bcp\\s+|\\bdd\\s|\\bmkfs\\b|\\bgit\\s+push|\\bgit\\s+commit|\\bgit\\s+add|\\bgit\\s+stash|\\bgit\\s+rebase|\\bgit\\s+clean|\\bgit\\s+branch\\s+-[dD]|\\bgit\\s+reset|\\bgit\\s+checkout\\s+\\.|\\bapt\\s|\\byum\\s|\\bbrew\\s+install|\\bnpm\\s+install|\\bsudo\\s|\\bdocker\\s|\\bkubectl\\s|>\\s+/|>>\\s+/)\"; then printf \"{\\\"hookSpecificOutput\\\":{\\\"hookEventName\\\":\\\"PreToolUse\\\",\\\"permissionDecision\\\":\\\"allow\\\"}}\"; else printf \"{\\\"hookSpecificOutput\\\":{\\\"hookEventName\\\":\\\"PreToolUse\\\",\\\"permissionDecision\\\":\\\"ask\\\",\\\"permissionDecisionReason\\\":\\\"contains destructive operation, review carefully\\\"}}\"; fi'"
          }
        ]
      },
      {
        "matcher": "Bash",
        "hooks": [
          {
            "type": "command",
            "command": "bash -c 'CMD=$(jq -r \".tool_input.command\"); S=$(printf \"%s\" \"$CMD\" | sed -e \"s/'\\''[^'\\'']*'\\''//g\" -e \"s/\\\"[^\\\"]*\\\"//g\"); if printf \"%s\" \"$S\" | grep -qE \"(^|[;&|(){}]|[[:space:]]do|[[:space:]]then|[[:space:]]else)[[:space:]]*timeout[[:space:]]\"; then printf \"{\\\"hookSpecificOutput\\\":{\\\"hookEventName\\\":\\\"PreToolUse\\\",\\\"permissionDecision\\\":\\\"deny\\\",\\\"permissionDecisionReason\\\":\\\"macOS has no timeout command on this host, so timeout N ... exits 127 with empty output and silently hides the real result (a remote ssh sweep can look idle when it is not). Use ssh -o ConnectTimeout=N, or gtimeout N (brew coreutils), or for a remote Linux host put timeout inside the ssh quotes.\\\"}}\"; fi'"
          }
        ]
      }
    ]
  },
  "outputStyle": "Concise",
  "model": "opus",
  "enabledPlugins": {
    "heroui-skills@claude-settings": true,
    "typescript-skills@claude-settings": true,
    "reusable-app-components@claude-settings": true,
    "qa@claude-settings": true,
    "agent-browser@claude-settings": true,
    "intelligent-compact@claude-settings": true,
    "github-dev@claude-settings": true,
    "humanize@claude-settings": true
  },
  "extraKnownMarketplaces": {
    "claude-settings": {
      "source": {
        "source": "github",
        "repo": "fcakyon/claude-codex-settings"
      }
    }
  },
  "showThinkingSummaries": true,
  "autoDreamEnabled": true,
  "spinnerTipsEnabled": false,
  "alwaysThinkingEnabled": true,
  "effortLevel": "medium",
  "cleanupPeriodDays": 9999,
  "showClearContextOnPlanAccept": false,
  "autoUpdatesChannel": "latest",
  "skillListingBudgetFraction": 0.02
}
.codex/config-zai.toml
# Z.ai GLM recipe for Codex CLI.
# Copy the blocks below into ~/.codex/config.toml to activate.
# This file is NOT auto-loaded. Codex only reads config.toml.
#
# Source: https://docs.z.ai/devpack/tool/codex
# Z.ai now serves an OpenAI Responses endpoint at /api/v1, so no local proxy
# is needed (unlike the Kimi and MiniMax recipes). wire_api must be "responses".
#
# Codex reads model limits from a catalog file, so also create ~/.codex/models.json:
#
# {
#   "models": [
#     {
#       "slug": "glm-5.3",
#       "display_name": "glm-5.3",
#       "description": "Z.ai flagship model",
#       "default_reasoning_level": "max",
#       "supported_reasoning_levels": [
#         { "effort": "low", "description": "Light reasoning" },
#         { "effort": "high", "description": "Deeper reasoning" },
#         { "effort": "max", "description": "Deep reasoning" }
#       ],
#       "shell_type": "shell_command",
#       "visibility": "list",
#       "supported_in_api": true,
#       "priority": 0,
#       "base_instructions": "",
#       "supports_reasoning_summaries": true,
#       "default_reasoning_summary": "none",
#       "support_verbosity": false,
#       "apply_patch_tool_type": "freeform",
#       "truncation_policy": { "mode": "bytes", "limit": 10000 },
#       "context_window": 1048576,
#       "max_context_window": 1048576,
#       "effective_context_window_percent": 95,
#       "supports_parallel_tool_calls": true,
#       "experimental_supported_tools": [],
#       "input_modalities": ["text"]
#     }
#   ]
# }
#
# Claude Code users: see .claude/settings-zai.json, which uses the
# Anthropic-compatible endpoint and the glm-5.3[1m] 1M-context model ID.

model = "glm-5.3"
model_provider = "ZAI"
model_reasoning_effort = "max"
model_catalog_json = "~/.codex/models.json"

[model_providers.ZAI]
name = "ZAI"
base_url = "https://api.z.ai/api/v1"
experimental_bearer_token = "your_zai_api_key"
wire_api = "responses"