Tools
Zai Image
Z.AI CogView-4 and GLM-Image generation plugin for OpenClaw
Configuration Example
{
"plugins": {
"entries": {
"zai-image": { "enabled": true }
},
"allow": ["zai-image"],
"load": {
"paths": [
"/path/to/.openclaw/plugins/zai-image"
]
}
}
}
README
# Z.AI Image Generation Plugin for OpenClaw
An [OpenClaw](https://openclaw.ai) code plugin that adds Z.AI's image generation models (**CogView-4** and **GLM-Image**) as a first-class image generation provider.
## Why This Plugin Exists
OpenClaw ships with a built-in Z.AI provider, but it only covers **text/chat completions** (GLM-5.2, GLM-5-Turbo, etc.). The image generation models — [CogView-4](https://docs.z.ai/guides/image/cogview-4) and [GLM-Image](https://docs.z.ai/guides/image/glm-image) — are not included, because they use a separate API endpoint (`/paas/v4/images/generations`) with a different request/response format.
This plugin bridges that gap by registering a dedicated `zai-image` image generation provider that talks directly to the Z.AI Images API.
## Features
- ✅ Supports **GLM-Image**, **CogView-4** (`cogview-4-250304`), **CogView-4** (legacy), and **CogView-3 Flash**
- ✅ Automatic image download (Z.AI returns URLs, plugin fetches and converts to buffers)
- ✅ Reads existing Z.AI API key from `models.providers.zai` config — no extra setup if you already use Z.AI for chat
- ✅ Quality mapping (`hd` / `standard`)
- ✅ Size hints per model
- ❌ No image editing (the Z.AI API does not support edits)
## Installation
### Option A: Local plugin directory
1. Clone or copy this folder to your plugins directory:
```bash
git clone https://github.com/yakinrei/openclaw-zai-image.git ~/.openclaw/plugins/zai-image
```
2. Add to your `openclaw.json`:
```json
{
"plugins": {
"entries": {
"zai-image": { "enabled": true }
},
"allow": ["zai-image"],
"load": {
"paths": [
"/path/to/.openclaw/plugins/zai-image"
]
}
}
}
```
3. (Optional) Set as your default image generation model:
```json
{
"imageGenerationModel": {
"primary": "zai-image/cogview-4-250304"
}
}
```
4. Restart your gateway:
```bash
openclaw gateway restart
```
### Option B: ClawHub
```bash
clawhub package install yakinrei/zai-image
```
## Configuration
The plugin reads your existing Z.AI API key from `models.providers.zai.apiKey` in `openclaw.json`. If that's not set, it falls back to the `ZAI_API_KEY` environment variable.
**Important:** The plugin uses the **general API endpoint** (`https://api.z.ai/api/paas/v4`), not the Coding Plan endpoint (`/api/coding/paas/v4`). This is because image generation is billed separately from the Coding Plan.
## ⚠️ Limitations & Important Notes
### Z.AI Coding Plans Do NOT Include Image Generation
The **GLM Coding Plan** (Lite / Pro / Max) is a subscription **for coding only** — it covers text models like GLM-5.2 and GLM-5-Turbo via the `/api/coding/paas/v4` endpoint.
**Image generation is pay-as-you-go** and billed per image:
| Model | Price per Image |
|-------------|-----------------|
| GLM-Image | $0.015 |
| CogView-4 | $0.01 |
To use this plugin, you need to **add balance (credits) to your Z.AI account** at [z.ai/manage-apikey/billing](https://z.ai/manage-apikey/billing). The Coding Plan subscription quota cannot be used for image generation.
### Other Limitations
- **Single image per request** — the Z.AI API currently returns one image per call
- **No image editing** — Z.AI's image endpoint does not support reference image editing
- **URL expiry** — generated image URLs expire after 30 days; the plugin downloads them immediately so this is not an issue for local storage
- **Content filtering** — Z.AI enforces content safety filters; requests that violate their policies will be rejected
- **Quality differences** — `glm-image` defaults to `hd` quality (~20s generation), while `cogview-4` defaults to `standard` (~5-10s)
## Supported Models
| Model ID | Label | Default Size | Notes |
|-----------------------|--------------------|---------------|------------------------------|
| `cogview-4-250304` | CogView-4 | 1024x1024 | Latest CogView-4 release |
| `glm-image` | GLM-Image | 1280x1280 | Higher quality, slower |
| `cogview-4` | CogView-4 (legacy) | 1024x1024 | Legacy alias |
| `cogview-3-flash` | CogView-3 Flash | 1024x1024 | Fastest, lower quality |
## API Reference
This plugin calls the [Z.AI Generate Image API](https://docs.z.ai/api-reference/image/generate-image):
```
POST https://api.z.ai/api/paas/v4/images/generations
Authorization: Bearer <your-api-key>
Content-Type: application/json
{
"model": "cogview-4-250304",
"prompt": "A cute kitten on a windowsill",
"size": "1024x1024"
}
```
Response:
```json
{
"created": 1760335349,
"data": [{ "url": "https://..." }]
}
```
## License
MIT
## Author
[@yakinrei](https://github.com/yakinrei)
tools
Comments
Sign in to leave a comment