Z AI2API
将 Z.ai Chat 代理为 OpenAI/Anthropic Compatible 格式,支持多模型列表映射、免令牌、智能处理思考链、图片上传等功能;Z.ai ZtoApi z2api ZaitoApi zai X-Signature 签名 GLM 4.5 v 4.6
What is Z AI2API?
Z AI2API is a Model Context Protocol (MCP) server that allows AI assistants like Claude, Cursor, and VS Code to 将 z.ai chat 代理为 openai/anthropic compatible 格式,支持多模型列表映射、免令牌、智能处理思考链、图片上传等功能;z.ai ztoapi z2api zaitoapi zai x-signature 签名 glm 4.5 v 4.6
将 Z.ai Chat 代理为 OpenAI/Anthropic Compatible 格式,支持多模型列表映射、免令牌、智能处理思考链、图片上传等功能;Z.ai ZtoApi z2api ZaitoApi zai X-Signature 签名 GLM 4.5 v 4.6
This server falls under the APIs category on MCPgee, the world's largest MCP server directory with 33,000+ servers.
Features
- 将 Z.ai Chat 代理为 OpenAI/Anthropic Compatible 格式,支持多模型列表映射、免令牌
Use Cases
Maintainer
Works with
Installation
Manual Installation
npx z-ai2apiConfiguration
Configuration Details
claude_desktop_config.json
Performance
Response Metrics
Resource Usage
How to Set Up and Use Z AI2API
Z AI2API is a proxy server that converts Z.ai Chat (powered by Zhipu AI's GLM models) into an OpenAI-compatible and Anthropic-compatible API format, allowing any tool that speaks the OpenAI API to use Z.ai's GLM-4.5, GLM-4.6, and related models without needing a separate API token. It supports anonymous visitor mode that auto-obtains a random session token, intelligently handles chain-of-thought reasoning output in multiple formats, and enables image uploads for vision models when a real account token is supplied. Developers use it as a local bridge to access Z.ai models from OpenAI-compatible clients and MCP tools.
Prerequisites
- Python 3.12 or higher installed
- pip for installing Python packages
- A Z.ai account token (optional; anonymous mode works without one)
- An MCP-compatible client or OpenAI-compatible tool to consume the proxy
Clone the repository
Download the Z.ai2api source code from GitHub.
git clone https://github.com/hmjz100/Z.ai2api.git
cd Z.ai2apiInstall Python dependencies
Install all required packages listed in requirements.txt.
pip install -r requirements.txtCreate a .env configuration file
Configure the proxy by creating a .env file. In anonymous mode (default) no token is required. Set TOKEN only if you want to use image upload / vision features with a real Z.ai account.
BASE=https://chat.z.ai
PORT=8080
MODEL=GLM-4.5
ANONYMOUS_MODE=true
THINK_TAGS_MODE=reasoning
DEBUG_MODE=false
# Optional: TOKEN=your_z_ai_account_tokenStart the proxy server
Run the Flask/FastAPI application. By default it listens on port 8080.
python app.pyPoint your MCP client or OpenAI-compatible tool at the proxy
Set the API base URL to http://localhost:8080/v1 in your client. The proxy exposes the standard /v1/chat/completions and /api/models endpoints.
Z AI2API Examples
Client configuration
Claude Desktop MCP server config that launches Z.ai2api as a local proxy process. Because this is an API proxy rather than a stdio MCP server, integrate it via an HTTP-based MCP adapter pointing at the local port.
{
"mcpServers": {
"z-ai2api": {
"command": "python",
"args": ["/absolute/path/to/Z.ai2api/app.py"],
"env": {
"PORT": "8080",
"ANONYMOUS_MODE": "true",
"THINK_TAGS_MODE": "reasoning"
}
}
}
}Prompts to try
Example API calls you can make to the proxy once it is running on port 8080.
- "Send a chat completion request to http://localhost:8080/v1/chat/completions using model GLM-4.5"
- "List available models via GET http://localhost:8080/api/models"
- "Upload an image in the messages array to use GLM vision capabilities (requires TOKEN in .env)"Troubleshooting Z AI2API
Anonymous mode returns an authentication error from Z.ai
The Z.ai anonymous token endpoint may be rate-limited or temporarily unavailable. Try setting ANONYMOUS_MODE=false and providing a real TOKEN in the .env file, or wait a few minutes and retry.
Reasoning / chain-of-thought text is mixed into the main content
Adjust THINK_TAGS_MODE in your .env file. Use 'reasoning' to separate thinking into reasoning_content, 'strip' to remove it entirely, 'think' to wrap it in <think> tags, or 'details' to wrap it in a collapsible <details> block.
Image uploads fail even with a valid token
Image uploads require ANONYMOUS_MODE=false and a real Z.ai session token in the TOKEN variable. Also confirm you are using a GLM vision model such as GLM-4V.
Frequently Asked Questions about Z AI2API
What is Z AI2API?
Z AI2API is a Model Context Protocol (MCP) server that 将 z.ai chat 代理为 openai/anthropic compatible 格式,支持多模型列表映射、免令牌、智能处理思考链、图片上传等功能;z.ai ztoapi z2api zaitoapi zai x-signature 签名 glm 4.5 v 4.6 It connects AI assistants to external tools and data sources through a standardized interface.
How do I install Z AI2API?
Follow the installation instructions on the Z AI2API GitHub repository. Clone the repo, install dependencies, and add the server config to your AI client.
Which AI clients work with Z AI2API?
Z AI2API works with all major MCP-compatible AI clients including Claude Desktop, Claude Code, Cursor, VS Code (GitHub Copilot), Windsurf, and Cline.
Is Z AI2API free to use?
Yes, Z AI2API is open source and available under the AGPL-3.0 license. You can use it freely in both personal and commercial projects.
Z AI2API Alternatives — Similar APIs Servers
Looking for alternatives to Z AI2API? Here are other popular apis servers you can use with Claude, Cursor, and VS Code.
Kong
★ 43.4k🦍 The API and AI Gateway
API Mega List
★ 5.4kThis GitHub repo is a powerhouse collection of APIs you can start using immediately to build everything from simple automations to full-scale applications. One of the most valuable API lists on GitHub—period. 💪
Fetch
★ 5.4kFetch web content and convert to markdown for AI consumption
Fusio
★ 2.1kSelf-Hosted API Management for Builders
Korean Law
★ 1.8k국가법령정보MCP v4.0 | 법제처 41개 API → 17개 MCP 도구. 법령·판례·조례 검색 + LLM 환각 방지 인용검증 + 조문 영향 그래프(impact_map) + 시점 비교 자동 diff(time_travel) + 시민 5단계 실행 가이드(action_plan) | 41 Korean legal APIs → 17 MCP tools
RuleGo
★ 1.5k⛓️RuleGo is a lightweight, high-performance, embedded, next-generation component orchestration rule engine framework for Go.
Browse More APIs MCP Servers
Explore all apis servers available in the MCPgee directory. Each server includes setup guides for Claude, Cursor, and VS Code.
Set Up Z AI2API in Your Editor
Choose your AI client for step-by-step setup instructions.
Quick Config Preview
Add this to your claude_desktop_config.json or .cursor/mcp.json
Ready to use Z AI2API?
Browse our complete directory of 33,000+ MCP servers, read setup guides for your editor, and start building with the Model Context Protocol.