Access Z.ai (Zhipu) coding models within GitHub Copilot Chat
🌐 Z.ai • 📖 API Docs • 🔑 Get API Key
- 🧠 Z.ai Models - Access Z.ai (GLM) models in Copilot Chat, including Coding Plan and general Z.ai API endpoints
- 🔀 Model Picker - Select Z models via the model selector dropdown on any Copilot Chat conversation
- 💬 Chat Participant - Invoke
@zdirectly in Copilot Chat for a dedicated, history-aware Z conversation - 🔧 Tool Calling - Function calling support for agentic workflows
- 🌐 First-Party Web Tools -
webSearchandwebFetchlanguage model tools that call the Z.ai API directly - 🖼️ Vision via MCP - Image understanding is routed through the Vision MCP server
- 🔒 Secure - API key stored using VS Code's encrypted secrets API
- ⚡ Streaming - Real-time response streaming for faster interactions
- 📊 Usage Status Bar - Status bar item tracks subscription usage limits
- VS Code 1.120.0 or higher
- GitHub Copilot Chat extension installed (required)
- A valid Z.ai API key
- Install from VS Code Marketplace (or install the
.vsixfile) - Open Command Palette (
Ctrl+Shift+P/Cmd+Shift+P) - Run:
Z: Manage API Key - Enter your API key from z.ai
- Go to Z.ai Console
- Sign up or log in with your account
- Navigate to API Keys section
- Click Create new key
- Copy the key and paste it into VS Code when prompted
To use a Z model in an existing Copilot Chat conversation without the @z handle:
- Open GitHub Copilot Chat panel in VS Code
- Click the model selector dropdown
- Choose a Z.ai model
- Start chatting!
Type @z in any Copilot Chat input to direct the conversation to Z.ai. The participant is sticky — once invoked, it stays active for the thread.
@z explain the architecture of this project
When a Z_API_KEY is configured, the extension shows a usage item on the right side of the status bar. Click the status bar item to toggle between hourly and weekly views.
Tooltip includes:
- Token quota windows and progress bars
- MCP time-limit usage windows
- Last updated time
You can also refresh usage manually via command palette:
Z: Refresh Usage Stats
Related settings:
zModels.usage.enabledzModels.usage.refreshInterval
This provider supports the following modelOptions keys (used internally by VS Code model requests and useful for extension contributors):
temperature: numbertopP: numbersafePrompt: booleandoSample: boolean(alias:do_sample)stop: string[](only the first stop string is sent)userId: string(alias:user_id; must be 6–128 characters)reasoningEffort: string(alias:reasoning_effort; GLM-5.2+ only; valuesmax|xhigh|high|medium|low|minimal|none; only applied when thinking is enabled)
Thinking controls:
thinking: boolean(falsemaps tothinking.type = "disabled")thinkingType: "enabled" | "disabled"clearThinking: boolean(alias:clear_thinking)
Structured output:
jsonMode: boolean(maps toresponse_format: { type: "json_object" })responseFormat: "json_object" | { type: "json_object" }
Web search tool:
webSearch: boolean | object(alias:web_search)trueenables default web search tool config- object passes through as
web_searchtool configuration
Notes:
- Requests use streaming (
stream: true) and tool streaming (tool_stream: true) when tools are present. - Each chat request includes a generated
request_idfor tracing support. - Tool calls are assembled incrementally from SSE deltas and emitted as soon as arguments become valid JSON.
- Cache usage is automatic server-side; cached prompt token counts are logged when returned by the API (
usage.prompt_tokens_details.cached_tokens). - Token counting uses the Z.ai tokenizer API for supported GLM-4.5 / GLM-4.6 models and falls back to a compatible approximation (
cl100k_base) for other models.
- Your API key is stored securely using VS Code's encrypted secrets API
- No data is stored by this extension - all requests go directly to Z.ai
- See Z.ai Privacy Policy for details
This extension supports Model Context Protocol (MCP) servers for enhanced capabilities:
- Vision MCP: Image processing and analysis
- Search MCP: Web and code search capabilities
- Reader MCP: Document reading and PDF processing
- ZRead MCP: Advanced reading and contextual analysis
When an image is attached in chat and Vision MCP is enabled, the extension prefers MCP-based image analysis.
Alternatively, the first-party webSearch and webFetch language model tools (see First-Party Web Tools) call the Z.ai API directly and work without MCP servers.
You can enable/disable MCP servers in VS Code settings:
- Open VS Code Settings (
Ctrl+,orCmd+,) - Search for "Z.ai"
- Enable/disable individual MCP servers as needed
-
command 'z-chat.manageApiKey' not found- Ensure you are running the latest extension build and reload VS Code (
Developer: Reload Window). - This usually indicates extension activation failed before command registration.
- Ensure you are running the latest extension build and reload VS Code (
-
Selecting Z.ai in Model Manager does nothing
- This is typically the same activation issue as above; update/reload the extension first.
-
No registered MCP servers
- MCP server definitions are registered eagerly, but they are only resolvable/startable after a valid API key is stored.
- MCP registration depends on VS Code builds that include MCP provider APIs. In builds without that API, the extension still works for chat/models, but MCP server registration is skipped.
Beyond the MCP servers, the extension registers two first-party language model tools that call the Z.ai API directly and can be referenced in prompts or used by agentic models:
z_webSearch(webSearch) - Search the web and return results using Z.ai's search engine.z_webFetch(webFetch) - Fetch a URL and return its readable text content (bounded to ~200KB, http(s) only).
Both are enabled by default and can be toggled via settings:
zModels.tools.webSearch- Enable thewebSearchlanguage model toolzModels.tools.webFetch- Enable thewebFetchlanguage model tool
pnpm install
pnpm run compile # type-check + lint + bundle
pnpm run watch # parallel watch for type-check and bundleNote:
dist/is gitignored. Rebuild (pnpm run compileorpnpm run package) before running the integration tests or launching the debug host, or you may load a stale bundle.
pnpm test # unit tests (Vitest)
pnpm run test:coverage # unit tests with coverage
pnpm run test:extension # VS Code integration testsOpen the project in VS Code and press F5 to launch the Extension Development Host with the extension loaded.
MIT License - See LICENSE for details.
Maintained by Daniel Sieradski (@selfagency).
