GLM-V Prompt Generation Skill
Analyze reference images or videos and generate professional prompts for AI image/video generation tools.
When to Use
- - Generate prompts for text-to-image tools (Midjourney, Stable Diffusion, DALL-E, etc.)
- Generate prompts for text-to-video tools (Sora, Runway, Kling, Pika, etc.)
- User mentions "生成prompt", "文生图prompt", "文生视频prompt", "prompt工程", "参考图生成prompt", "generate prompt"
- User provides an image/video and wants to recreate or remix it
- Extract prompt ideas from reference visual content
Supported Input Types
| Type | Formats | Max Size | Max Count | Base64 |
|---|
| Image | jpg, png, jpeg | 5MB / 6000×6000px | 50 | ✅ |
| Video |
mp4, mkv, mov | 200MB | — | ❌ (URL only) |
⚠️ Images and videos cannot be used in the same request.
⚠️ Videos only support URLs — local paths and base64 are NOT supported.
📋 Output Display Rules (MANDATORY)
After running the script, you must display the full prompt output exactly as returned. Do not summarize, truncate, or only say "prompt generated". Users need the complete prompt (especially the English prompt) for direct copy/paste.
- - Show the full output: content analysis + prompt + prompt breakdown
- In
auto mode, show both text-to-image and text-to-video prompts - English prompts are core output and must be shown completely
- If output was saved (
-o), provide the file path and show file content
Output Modes
| Mode | Description |
|---|
| INLINECODE2 | Generate prompts for text-to-image tools (default) |
| INLINECODE3 |
Generate prompts for text-to-video tools |
|
auto | Generate prompts for both image and video |
Resource Links
Chat Completions / 对话补全 |
Prerequisites
API Key Setup / API Key 配置(Required / 必需)
This script reads the key from the ZHIPU_API_KEY environment variable and shares it with other Zhipu skills.
脚本通过 ZHIPU_API_KEY 环境变量获取密钥,与其他智谱技能共用同一个 key。
Get Key / 获取 Key: Visit Zhipu Open Platform API Keys / 智谱开放平台 API Keys to create or copy your key.
Setup options / 配置方式(任选一种):
- 1. OpenClaw config (recommended) / OpenClaw 配置(推荐): Set in
openclaw.json under skills.entries.glmv-prompt-gen.env:
CODEBLOCK0
- 2. Shell environment variable / Shell 环境变量: Add to
~/.zshrc:
CODEBLOCK1
💡 If you already configured another Zhipu skill (for example zhipu-tools or glmv-caption), they share the same ZHIPU_API_KEY, so no extra setup is needed.
💡 如果你已为其他智谱 skill(如 zhipu-tools、glmv-caption)配置过 key,它们共享同一个 ZHIPU_API_KEY,无需重复配置。
How to Use
Image → Text-to-Image Prompt
CODEBLOCK2
Image → Text-to-Video Prompt
CODEBLOCK3
Image → Both (Image + Video Prompts)
CODEBLOCK4
Video → Text-to-Video Prompt
CODEBLOCK5
Save Result to File
CODEBLOCK6
Custom Model
CODEBLOCK7
Output Example (image mode)
CODEBLOCK8
CLI Reference
CODEBLOCK9
| Parameter | Required | Description |
|---|
| INLINECODE16 , INLINECODE17 | One of | Image paths or URLs (jpg/png/jpeg, base64 OK) |
| INLINECODE18 , INLINECODE19 |
One of | Video URLs (mp4/mkv/mov, URL only) |
|
--mode,
-m | No | Output mode:
image (default),
video, or
auto |
|
--model | No | Model name (default:
glm-4.6v) |
|
--temperature,
-t | No | Sampling temperature 0-1 (default: 0.6) |
|
--max-tokens | No | Max output tokens (default: 2048) |
|
--thinking | No | Enable thinking/reasoning mode |
|
--stream | No | Enable streaming output |
|
--output,
-o | No | Save result to file |
|
--pretty | No | Pretty-print JSON error output |
Error Handling
API key not configured: → Guide user to configure INLINECODE35
Authentication failed (401/403): → API key invalid/expired → check at Zhipu API Keys / 智谱官网
Rate limit (429): → Quota exhausted → wait and retry
Content filtered: → warning field present → content blocked by safety review
Timeout: → Video processing may take time → increase timeout or use smaller files
GLM-V 提示词生成技能
分析参考图像或视频,为AI图像/视频生成工具生成专业提示词。
使用时机
- - 为文生图工具(Midjourney、Stable Diffusion、DALL-E等)生成提示词
- 为文生视频工具(Sora、Runway、可灵、Pika等)生成提示词
- 用户提及生成prompt、文生图prompt、文生视频prompt、prompt工程、参考图生成prompt、generate prompt
- 用户提供图像/视频并希望重新创作或混搭
- 从参考视觉内容中提取提示词创意
支持的输入类型
| 类型 | 格式 | 最大大小 | 最大数量 | Base64 |
|---|
| 图像 | jpg、png、jpeg | 5MB / 6000×6000px | 50 | ✅ |
| 视频 |
mp4、mkv、mov | 200MB | — | ❌(仅URL) |
⚠️ 图像和视频不能在同一请求中使用。
⚠️ 视频仅支持URL — 不支持本地路径和base64。
📋 输出显示规则(强制)
运行脚本后,必须完整显示返回的提示词输出。不要进行摘要、截断或仅说提示词已生成。用户需要完整的提示词(尤其是英文提示词)以便直接复制/粘贴。
- - 显示完整输出:内容分析 + 提示词 + 提示词分解
- 在auto模式下,同时显示文生图和文生视频提示词
- 英文提示词是核心输出,必须完整显示
- 如果输出已保存(-o),提供文件路径并显示文件内容
输出模式
| 模式 | 描述 |
|---|
| image | 为文生图工具生成提示词(默认) |
| video |
为文生视频工具生成提示词 |
| auto | 同时为图像和视频生成提示词 |
资源链接
Chat Completions / 对话补全 |
前置条件
API密钥配置(必需)
本脚本从ZHIPUAPIKEY环境变量读取密钥,并与其他智谱技能共用同一个key。
获取密钥: 访问智谱开放平台API密钥创建或复制你的密钥。
配置方式(任选一种):
- 1. OpenClaw配置(推荐): 在openclaw.json的skills.entries.glmv-prompt-gen.env中设置:
json
glmv-prompt-gen: { enabled: true, env: { ZHIPUAPIKEY: 你的密钥 } }
- 2. Shell环境变量: 添加到~/.zshrc:
bash
export ZHIPU
APIKEY=你的密钥
💡 如果你已为其他智谱skill(如zhipu-tools、glmv-caption)配置过key,它们共享同一个ZHIPUAPIKEY,无需重复配置。
使用方法
图像 → 文生图提示词
bash
python scripts/prompt_gen.py --images https://example.com/photo.jpg
python scripts/prompt_gen.py --images /path/to/photo.png
图像 → 文生视频提示词
bash
python scripts/prompt_gen.py --images https://example.com/scene.jpg --mode video
图像 → 两者(图像+视频提示词)
bash
python scripts/prompt_gen.py --images https://example.com/photo.jpg --mode auto
视频 → 文生视频提示词
bash
python scripts/prompt_gen.py --videos https://example.com/clip.mp4 --mode video
保存结果到文件
bash
python scripts/prompt_gen.py --images photo.jpg --mode image -o prompt.md
自定义模型
bash
python scripts/prompt_gen.py --images photo.jpg --model glm-4.6v-flash
输出示例(图像模式)
内容分析
夜晚的赛博朋克城市景观,密集的摩天大楼,发光的霓虹灯招牌,雨湿的街道反射着五彩灯光。
提示词
Cyberpunk cityscape at night, towering skyscrapers with glowing neon signs,
rain-wet streets reflecting colorful lights, flying cars in the distance,
volumetric fog, dramatic lighting, ultra detailed, 8K, cinematic composition
提示词分解
- - 主体:带有霓虹灯的未来主义天际线摩天大楼
- 风格:赛博朋克、科幻
- 色彩:蓝紫色主导与霓虹点缀的冷暖对比
- 光照:霓虹辉光、湿面反射、体积雾
- 构图:具有层次深度的广角透视
- 氛围:神秘、未来主义、高科技
CLI参考
python scripts/prompt_gen.py (--images IMG [IMG...] | --videos VID [VID...]) [OPTIONS]
| 参数 | 必需 | 描述 |
|---|
| --images、-i | 二选一 | 图像路径或URL(jpg/png/jpeg,支持base64) |
| --videos、-v |
二选一 | 视频URL(mp4/mkv/mov,仅URL) |
| --mode、-m | 否 | 输出模式:image(默认)、video或auto |
| --model | 否 | 模型名称(默认:glm-4.6v) |
| --temperature、-t | 否 | 采样温度0-1(默认:0.6) |
| --max-tokens | 否 | 最大输出令牌数(默认:2048) |
| --thinking | 否 | 启用思考/推理模式 |
| --stream | 否 | 启用流式输出 |
| --output、-o | 否 | 将结果保存到文件 |
| --pretty | 否 | 美化打印JSON错误输出 |
错误处理
API密钥未配置: → 引导用户配置ZHIPUAPIKEY
身份验证失败(401/403): → API密钥无效/已过期 → 在智谱官网检查
速率限制(429): → 配额已用完 → 等待后重试
内容被过滤: → 存在warning字段 → 内容被安全审查拦截
超时: → 视频处理可能需要时间 → 增加超时时间或使用较小的文件