Z AI2API

v1.0.0APIsstable

将 Z.ai Chat 代理为 OpenAI/Anthropic Compatible 格式,支持多模型列表映射、免令牌、智能处理思考链、图片上传等功能;Z.ai ZtoApi z2api ZaitoApi zai X-Signature 签名 GLM 4.5 v 4.6

ai2apianthropic-claudechat2apichatglmclaude
Share:
143
Stars
0
Downloads
0
Weekly
0/5

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

Convert Z.ai Chat to OpenAI-compatible format
Support multi-model list mapping
Process thinking chain and image uploads
hmjz100

Maintainer

LicenseAGPL-3.0
Languagepython
Versionv1.0.0
UpdatedMay 20, 2026
Statushealthy
Maintenanceactive

Works with

ClaudeOpenAIwindowsmacoslinux

Installation

Manual Installation

npx z-ai2api

Configuration

Configuration Details

Config File

claude_desktop_config.json

Performance

Response Metrics

Response Time< 200ms
ThroughputMedium

Resource Usage

Memory UsageLow
CPU UsageLow

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
1

Clone the repository

Download the Z.ai2api source code from GitHub.

git clone https://github.com/hmjz100/Z.ai2api.git
cd Z.ai2api
2

Install Python dependencies

Install all required packages listed in requirements.txt.

pip install -r requirements.txt
3

Create 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_token
4

Start the proxy server

Run the Flask/FastAPI application. By default it listens on port 8080.

python app.py
5

Point 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.

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.

Quick Config Preview

{ "mcpServers": { "z-ai2api": { "command": "npx", "args": ["-y", "z-ai2api"] } } }

Add this to your claude_desktop_config.json or .cursor/mcp.json

Read the full setup guide →

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.

33,000+ ServersFree & Open SourceStep-by-Step Guides