Skip to content

API 端点目录

通过逆向分析 ZCode v3.0.1 / v2.13.0 JS Bundle 提取的所有 API 端点。


端点拓扑图

mermaid
graph TB
    subgraph Auth["认证端点 (chat.z.ai / zcode.z.ai)"]
        A1["GET /api/oauth/authorize<br/>OAuth 授权"]
        A2["POST /api/v1/oauth/token<br/>Token 交换"]
        A3["GET /api/oauth/userinfo<br/>用户信息"]
    end

    subgraph Business["业务认证 (api.z.ai)"]
        B1["POST /api/auth/z/login<br/>Business JWT"]
    end

    subgraph Billing["计费端点"]
        C1["GET /api/v1/zcode-plan/billing/current<br/>Start Plan 账单 ⚠️ WAF"]
        C2["GET /api/v1/zcode-plan/billing/balance<br/>Start Plan 余额 ⚠️ WAF"]
        C3["GET /api/biz/subscription/list<br/>Coding Plan 订阅"]
        C4["GET /api/monitor/usage/quota/limit<br/>使用配额"]
    end

    subgraph AI["AI 端点"]
        D1["POST /api/anthropic/v1/messages<br/>Z.AI Anthropic API"]
        D2["POST /open.bigmodel.cn/api/anthropic/v1/messages<br/>BigModel Anthropic API"]
    end

    subgraph Config["配置端点"]
        E1["GET /api/v1/client/configs<br/>客户端配置"]
    end

    A1 --> A2
    A2 --> B1
    B1 --> C1
    B1 --> C3
    B1 --> D1
    B1 --> D2

认证相关

端点用途方法认证方式
https://chat.z.ai/api/oauth/authorizeOAuth 授权GET用户交互
https://zcode.z.ai/api/v1/oauth/tokenToken 交换POST授权码
https://api.z.ai/api/auth/z/loginBusiness JWT 交换POSTaccess_token
https://chat.z.ai/api/oauth/userinfo用户信息GETBearer access_token
https://chat.z.ai/api/v1/auths/游客会话GET

套餐/计费

端点用途认证方式状态
https://zcode.z.ai/api/v1/zcode-plan/billing/currentStart Plan 账单Bearer JWT (zcode.z.ai session)⚠️ WAF 拦截
https://zcode.z.ai/api/v1/zcode-plan/billing/balanceStart Plan 余额Bearer JWT (zcode.z.ai session)⚠️ WAF 拦截
https://api.z.ai/api/biz/subscription/listCoding Plan 订阅Bearer JWT✅ 可用
https://api.z.ai/api/monitor/usage/quota/limit使用配额Bearer JWT✅ 可用
https://zcode.z.ai/api/v1/client/configs客户端配置✅ 可用
https://open.bigmodel.cn/api/biz/subscription/listBigModel 订阅Bearer JWT✅ 可用

AI API

端点用途认证方式
https://api.z.ai/api/anthropic/v1/messagesAI 对话 (Z.AI)x-api-key JWT
https://open.bigmodel.cn/api/anthropic/v1/messagesAI 对话 (BigModel)x-api-key API Key

请求格式

http
POST https://api.z.ai/api/anthropic/v1/messages
Content-Type: application/json
x-api-key: <zcode_jwt_token>
anthropic-version: 2023-06-01

{
    "model": "glm-5.1",
    "max_tokens": 64000,
    "stream": true,
    "messages": [
        {"role": "user", "content": [{"type": "text", "text": "Hello"}]}
    ]
}

OAuth 配置

Z.AI (默认)

javascript
{
    id: "zai",
    displayName: "Z.ai",
    authorizeUrl: "https://chat.z.ai/api/oauth/authorize",
    tokenUrl: "https://zcode.z.ai/api/v1/oauth/token",
    userinfoUrl: "https://chat.z.ai/api/oauth/userinfo",
    businessLoginUrl: "https://api.z.ai/api/auth/z/login",
    appId: "client_P8X5CMWmlaRO9gyO-KSqtg",
    redirectUri: "zcode://zai-auth/callback",
}

BigModel (智谱 AI)

javascript
{
    id: "zcode",
    displayName: "BigModel",
    authorizeUrl: "https://bigmodel.cn/login",
    tokenUrl: "https://zcode.z.ai/api/v1/oauth/token",
    userinfoUrl: "https://zcode.z.ai/api/oauth/userinfo",
    appId: "zcode",
    redirectUri: "zcode://oauth/callback",
}

请求头规范

javascript
{
    "User-Agent": "ZCode/${appVersion}",
    "HTTP-Referer": "https://zcode.z.ai",
    "X-Title": "Z Code@electron",
    "X-ZCode-App-Version": appVersion,
    "X-Platform": "${platform}-${arch}",
    "X-Release-Channel": "production",
    "X-Client-Language": locale,
    "X-Client-Timezone": timezone,
    "X-Os-Category": osCategory,
}

基于 GPL-3.0 协议开源