> ## Documentation Index
> Fetch the complete documentation index at: https://docs.vibetoken.cn/llms.txt
> Use this file to discover all available pages before exploring further.

# ZAI GLM Chat API

> ZAI GLM 聊天模型 —— GLM-4.5（4.5/4.5-Air/4.5V）、GLM-4.6（4.6/4.6V）、GLM-4.7 和 GLM-5（5/5.1/5.2）—— 通过 VibeToken，兼容 OpenAI 的聊天补全接口。

## 概述

ZAI 的 GLM 聊天模型运行在 VibeToken 上，通过标准的兼容 OpenAI 的聊天补全端点提供服务，支持流式输出和工具调用。涵盖 **GLM-4.5**、**GLM-4.6**、**GLM-4.7** 和 **GLM-5** 系列，包括具备视觉能力的 **GLM-4.5V** / **GLM-4.6V**。

|              |                                       |
| ------------ | ------------------------------------- |
| **Provider** | ZAI                                   |
| **Families** | `glm-4.5`、`glm-4.6`、`glm-4.7`、`glm-5` |
| **Modality** | 聊天                                    |
| **Input**    | 文本（`*V` 模型支持图像）                       |
| **Output**   | 文本                                    |

## 模型与定价

按每 100 万 tokens 计价，依据实际用量计费（无需预付）。Cache Read 为提示词缓存命中的折后费率（在 ZAI 公布该费率时适用，且不单独收取缓存写入费）；`—` 表示缓存部分按完整的 Input 费率计费。

| Model             | Input   | Output  | Cache Read |
| ----------------- | ------- | ------- | ---------- |
| `zai/glm-5.2`     | \$1.33  | \$4.18  | \$0.247    |
| `zai/glm-5.1`     | \$1.33  | \$4.18  | \$0.247    |
| `zai/glm-5`       | \$0.95  | \$3.04  | \$0.19     |
| `zai/glm-4.7`     | \$0.57  | \$2.09  | \$0.1045   |
| `zai/glm-4.6`     | \$0.57  | \$2.09  | \$0.1045   |
| `zai/glm-4.6v`    | \$0.285 | \$0.855 | \$0.0475   |
| `zai/glm-4.5`     | \$0.57  | \$2.09  | \$0.1045   |
| `zai/glm-4.5v`    | \$0.57  | \$1.71  | \$0.1045   |
| `zai/glm-4.5-air` | \$0.19  | \$1.045 | \$0.0285   |

实时费率和完整的聊天模型目录始终可通过
[Models API](/api-reference/models) 获取。

## 端点

```http theme={null}
POST https://vibetoken.cn/v1/chat/completions
```

与 OpenAI 的 [Chat Completions API](https://platform.openai.com/docs/api-reference/chat) 无缝兼容 ——
将你现有的 OpenAI 客户端指向 `https://vibetoken.cn/v1`，并使用
你的 VibeToken 密钥即可。有关所有支持的参数，请参阅完整的
[Chat Completions 参考文档](/api-reference/chat-completions)。

## 快速开始

```bash theme={null}
curl https://vibetoken.cn/v1/chat/completions \
  -H "Authorization: Bearer $VIBETOKEN_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "zai/glm-4.6",
    "messages": [
      { "role": "user", "content": "Explain mixture-of-experts in one sentence." }
    ]
  }'
```

```python theme={null}
from openai import OpenAI

client = OpenAI(
    base_url="https://vibetoken.cn/v1",
    api_key="$VIBETOKEN_API_KEY",
)

resp = client.chat.completions.create(
    model="zai/glm-5",
    messages=[{"role": "user", "content": "Hello!"}],
)
print(resp.choices[0].message.content)
```

设置 `"stream": true` 即可启用 token 流式输出（Server-Sent Events），
与 OpenAI API 完全一致。将 `model` 替换为上表中的任意 id 即可。

## 视觉输入（GLM-4.5V / GLM-4.6V）

`*V` 模型使用标准的 OpenAI content-parts 格式，可在文本之外同时接受图像：

```json theme={null}
{
  "model": "zai/glm-4.6v",
  "messages": [
    { "role": "user", "content": [
      { "type": "text", "text": "What's in this image?" },
      { "type": "image_url", "image_url": { "url": "https://example.com/cat.jpg" } }
    ]}
  ]
}
```
