jimeng-api-image-gen
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseJimeng API Image Generation
即梦(Jimeng)API图像生成
Generate high-quality AI images using Volcengine's Jimeng 4.0 API with text prompts or image inputs.
使用火山引擎即梦4.0 API,通过文本提示或图像输入生成高质量AI图像。
Output Behavior (Important)
输出行为(重要)
After image generation succeeds, you MUST display the image directly to the user!
When generation completes, output in the following format:
markdown

**Generation Info:**
- Prompt: [User's original prompt]
- Size: [Image dimensions]
- Save Path: [Local file path, if applicable]图像生成成功后,必须直接向用户展示图像!
生成完成后,请按照以下格式输出:
markdown

**生成信息:**
- 提示词:[用户原始提示词]
- 尺寸:[图像分辨率]
- 保存路径:[本地文件路径(如有)]Example Output
输出示例
markdown

**Generation Info:**
- Prompt: Shiba Inu under cherry blossom tree, warm sunlight, healing art style
- Size: 2304 × 1728
- Save Path: /generated_images/shiba_sakura.pngmarkdown

**生成信息:**
- 提示词:樱花树下的柴犬,温暖阳光,治愈系画风
- 尺寸:2304 × 1728
- 保存路径:/generated_images/shiba_sakura.pngNotes
注意事项
- Prefer markdown image syntax to display images directly
 - Also provide the online link for easy copying and sharing
- If saved locally, display the local file path
- For multiple images, display each one with numbered labels
- 优先使用Markdown图片语法 直接展示图像
 - 同时提供在线链接,方便复制和分享
- 若本地保存,需展示本地文件路径
- 多张图像,需为每张图像添加编号标签
Quick Start
快速开始
Step 1: Run Generation
步骤1:运行生成命令
bash
undefinedbash
undefinedText-to-image
文本生图
scripts/generate_image.py "A white Siamese cat sitting on a windowsill, sunlight streaming in"
scripts/generate_image.py "一只白色暹罗猫坐在窗台上,阳光洒入"
With specific size
指定尺寸
scripts/generate_image.py "Mountain sunset landscape" --size 2K
scripts/generate_image.py "山间日落风景" --size 2K
Image-to-image editing
图生图编辑
scripts/generate_image.py "Change to watercolor style" --images https://example.com/input.jpg
scripts/generate_image.py "转换为水彩风格" --images https://example.com/input.jpg
Save to file
保存到文件
scripts/generate_image.py "Serene lake at sunset" --output /generated_images/lake.png
undefinedscripts/generate_image.py "宁静的日落湖面" --output /generated_images/lake.png
undefinedAPI Configuration
API配置
| Parameter | Value | Description |
|---|---|---|
| Endpoint | | API base URL |
| Submit Action | | Submit async generation task |
| Query Action | | Query task result |
| Version | | API version |
| Service | | Service name for signing |
| Region | | Region for signing |
| req_key | | Jimeng AI 4.0 model identifier |
| 参数 | 值 | 描述 |
|---|---|---|
| Endpoint | | API基础地址 |
| Submit Action | | 提交异步生成任务 |
| Query Action | | 查询任务结果 |
| Version | | API版本 |
| Service | | 签名用服务名称 |
| Region | | 签名用区域 |
| req_key | | 即梦AI 4.0模型标识符 |
Image Size Options
图像尺寸选项
Preset Resolutions
预设分辨率
| Preset | Resolution | Pixels |
|---|---|---|
| 1K | 1024×1024 | 1,048,576 |
| 2K | 2048×2048 | 4,194,304 (default) |
| 4K | 4096×4096 | 16,777,216 |
| 预设值 | 分辨率 | 像素数 |
|---|---|---|
| 1K | 1024×1024 | 1,048,576 |
| 2K | 2048×2048 | 4,194,304(默认) |
| 4K | 4096×4096 | 16,777,216 |
Exact Dimensions
自定义精确尺寸
Use and together:
--width--heightbash
scripts/generate_image.py "prompt" --width 2560 --height 1440Recommended aspect ratios:
- 1:1 (2048x2048) - Social media posts
- 4:3 (2304x1728) - Presentations
- 16:9 (2560x1440) - Widescreen displays
- 9:16 (1440x2560) - Mobile vertical
- 3:2 (2496x1664) - Photography
Constraints:
- Width × Height must be in [1024×1024, 4096×4096]
- Aspect ratio (width/height) in [1/16, 16]
- Recommended: Use 2K+ for better quality
同时使用和参数:
--width--heightbash
scripts/generate_image.py "提示词" --width 2560 --height 1440推荐宽高比:
- 1:1(2048x2048)- 社交媒体帖子
- 4:3(2304x1728)- 演示文稿
- 16:9(2560x1440)- 宽屏显示器
- 9:16(1440x2560)- 移动端竖屏
- 3:2(2496x1664)- 摄影作品
限制条件:
- 宽×高必须在[1024×1024, 4096×4096]范围内
- 宽高比(宽/高)需在[1/16, 16]之间
- 推荐:使用2K及以上分辨率以获得更好画质
Command-Line Options
命令行选项
scripts/generate_image.py PROMPT [OPTIONS]
Arguments:
PROMPT Text prompt for image generation (required, max 800 chars)
Options:
--size SIZE Image size: 1K, 2K, 4K or WxH (default: 2K)
--width WIDTH Exact width (requires --height)
--height HEIGHT Exact height (requires --width)
--images URL [...] Input image URLs for image-to-image (max 10)
--watermark Add "AI Generated" watermark
--scale FLOAT Text influence 0-1 (default: 0.5)
--force-single Force single image output
--output PATH Download image to file
--json Output raw JSON response
Environment Variables:
VOLC_ACCESSKEY Access Key ID (required)
VOLC_SECRETKEY Secret Access Key (required)
JIMENG_API_URL API endpoint (default: https://visual.volcengineapi.com)
JIMENG_API_TIMEOUT Request timeout seconds (default: 120)
JIMENG_POLL_INTERVAL Polling interval seconds (default: 2)
JIMENG_MAX_POLL_ATTEMPTS Max polling attempts (default: 60)scripts/generate_image.py PROMPT [OPTIONS]
参数:
PROMPT 图像生成的文本提示词(必填,最多800字符)
选项:
--size SIZE 图像尺寸:1K、2K、4K或WxH(默认:2K)
--width WIDTH 精确宽度(需配合--height使用)
--height HEIGHT 精确高度(需配合--width使用)
--images URL [...] 图生图的输入图像URL(最多10个)
--watermark 添加“AI Generated”水印
--scale FLOAT 文本影响程度0-1(默认:0.5)
--force-single 强制输出单张图像
--output PATH 将图像下载到指定文件
--json 输出原始JSON响应
环境变量:
VOLC_ACCESSKEY Access Key ID(必填)
VOLC_SECRETKEY Secret Access Key(必填)
JIMENG_API_URL API端点(默认:https://visual.volcengineapi.com)
JIMENG_API_TIMEOUT 请求超时时间(秒,默认:120)
JIMENG_POLL_INTERVAL 轮询间隔(秒,默认:2)
JIMENG_MAX_POLL_ATTEMPTS 最大轮询次数(默认:60)Authentication
身份验证
This skill uses Volcengine IAM v4 signature authentication (HMAC-SHA256). The signing process:
- Build canonical request with headers:
content-type;host;x-content-sha256;x-date - Calculate SHA256 hash of canonical request
- Derive signing key: secret_key → date → region → service → "request"
- Sign the string-to-sign with derived key
- Add header to request
Authorization
Reference: HTTP请求示例
本Skill使用火山引擎IAM v4签名认证(HMAC-SHA256)。签名流程如下:
- 构建包含以下头部的规范请求:
content-type;host;x-content-sha256;x-date - 计算规范请求的SHA256哈希值
- 派生签名密钥:secret_key → 日期 → 区域 → 服务 → "request"
- 使用派生密钥对待签名字符串进行签名
- 在请求中添加头部
Authorization
参考:HTTP请求示例
Error Codes
错误码
| Code | Message | Description |
|---|---|---|
| 10000 | Success | Request successful |
| 50411 | Pre Img Risk Not Pass | Input image failed content check |
| 50511 | Post Img Risk Not Pass | Output image failed content check |
| 50412 | Text Risk Not Pass | Input text failed content check |
| 50413 | Post Text Risk Not Pass | Input text contains sensitive words |
| 50429 | Request Has Reached API Limit | Rate limit exceeded, retry later |
| 50500 | Internal Error | Server error |
| timeout | Request timeout | Increase JIMENG_API_TIMEOUT |
| 代码 | 消息 | 描述 |
|---|---|---|
| 10000 | Success | 请求成功 |
| 50411 | Pre Img Risk Not Pass | 输入图像未通过内容审核 |
| 50511 | Post Img Risk Not Pass | 输出图像未通过内容审核 |
| 50412 | Text Risk Not Pass | 输入文本未通过内容审核 |
| 50413 | Post Text Risk Not Pass | 输入文本包含敏感词汇 |
| 50429 | Request Has Reached API Limit | 超出API调用限制,请稍后重试 |
| 50500 | Internal Error | 服务器内部错误 |
| timeout | Request timeout | 请求超时,请增大JIMENG_API_TIMEOUT值 |
Input/Output Limits
输入/输出限制
Input Images:
- Format: JPEG, PNG only
- Max files: 10 images
- Max size: 15MB per image
- Max resolution: 4096×4096
- Aspect ratio (W/H): [1/3, 3]
Output:
- Max images: 15 - (input image count)
- Format: PNG
- URL validity: 24 hours
输入图像:
- 格式:仅支持JPEG、PNG
- 最大数量:10张图像
- 单张最大尺寸:15MB
- 最大分辨率:4096×4096
- 宽高比(W/H):[1/3, 3]
输出:
- 最大图像数量:15 - 输入图像数量
- 格式:PNG
- URL有效期:24小时