Z.ai Chat Provider for VS Code

Integrates Z.ai (智谱AI) models into VS Code Copilot Chat with advanced features including vision support, tool calling, and thinking process display.
Features
Installation
From Marketplace (Coming Soon)
code --install-extension Ryosuke-Asano.zai-vscode-chat
From Source
- Clone the repository:
git clone https://github.com/Ryosuke-Asano/zai-provider-extension.git
cd zai-provider-extension
- Install dependencies:
npm install
- Compile the project:
npm run compile
- Package the extension:
npm run package
- Install the
.vsix file:
code --install-extension zai-vscode-chat-*.vsix
Setup
- Open VS Code
- Open Command Palette (
Cmd/Ctrl + Shift + P)
- Run
Z.ai: Manage Z.ai Provider
- Enter your Z.ai API key
Get your API key from Z.ai Platform.
Usage
Once configured, select Z.ai as your chat provider in VS Code Copilot Chat:
- Open the Chat view (
Cmd/Ctrl + Alt + I)
- Click the provider selector
- Choose a Z.ai model (GLM-4.7, GLM-4.7 Flash, or GLM-5)
- Note: GLM-4.6V is used internally for image processing and is not selectable
Configuration
| Setting |
Type |
Default |
Description |
zai.enableThinking |
boolean |
true |
Enable thinking/reasoning process display in chat responses |
Supported Models
User-Selectable Models
| Model |
Context Window |
Max Output |
Vision |
Tools |
| GLM-4.7 |
200,000 |
131,072 |
No |
Yes |
| GLM-4.7 Flash |
200,000 |
131,072 |
No |
Yes |
| GLM-5 |
200,000 |
131,072 |
No |
Yes |
Internal Models (Not Exposed)
| Model |
Context Window |
Max Output |
Vision |
Tools |
Purpose |
| GLM-4.6V |
128,000 |
16,000 |
Yes |
Yes |
Image analysis fallback for non-vision models |
MCP Integration
This extension integrates with Z.ai's MCP (Model Context Protocol) servers:
- web-search-prime: Web search capabilities
- web-reader: URL to text/markdown conversion
- zread: GitHub repository file reading
- vision-mcp: Image analysis
Development
See CONTRIBUTING.md for detailed development guidelines.
Quick Start
# Install dependencies
npm install
# Watch for changes
npm run watch
# Run tests
npm test
# Lint code
npm run lint
# Format code
npm run format
Project Structure
src/
├── extension.ts # Extension entry point, activation
├── provider.ts # Main chat provider implementation
├── types.ts # Type definitions and model configuration
├── mcp.ts # MCP client for tool integration
└── utils.ts # Utility functions for message/tool conversion
Requirements
- VS Code 1.104.0 or later
- Node.js 20 or later (for development)
- Z.ai API key
Troubleshooting
API Key Issues
If you see authentication errors:
- Run
Z.ai: Manage Z.ai Provider
- Verify your API key is correct
- Ensure your API key has active credits
Vision Not Working
For non-vision models (GLM-4.7, GLM-4.7 Flash):
- Images are automatically converted to text descriptions using GLM-OCR MCP
- If GLM-OCR fails, the extension internally uses GLM-4.6V for image analysis
- GLM-4.6V is not selectable by users—it is only used as an internal fallback
Large Context Errors
If you encounter token limit errors:
- Reduce the amount of code/context in your message
- The extension enforces model-specific context limits
Changelog
See CHANGELOG.md for version history.
License
MIT © 2025 Ryosuke Asano
License
Links