jimeng-api-image-gen

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Jimeng 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
![Generated Image](IMAGE_URL)

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

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

Example Output

输出示例

markdown
![Shiba Inu under cherry blossoms](https://example.com/image.png)

**Generation Info:**
- Prompt: Shiba Inu under cherry blossom tree, warm sunlight, healing art style
- Size: 2304 × 1728
- Save Path: /generated_images/shiba_sakura.png
markdown
![樱花树下的柴犬](https://example.com/image.png)

**生成信息:**
- 提示词:樱花树下的柴犬,温暖阳光,治愈系画风
- 尺寸:2304 × 1728
- 保存路径:/generated_images/shiba_sakura.png

Notes

注意事项

  1. Prefer markdown image syntax
    ![description](URL)
    to display images directly
  2. Also provide the online link for easy copying and sharing
  3. If saved locally, display the local file path
  4. For multiple images, display each one with numbered labels
  1. 优先使用Markdown图片语法
    ![描述](URL)
    直接展示图像
  2. 同时提供在线链接,方便复制和分享
  3. 若本地保存,需展示本地文件路径
  4. 多张图像,需为每张图像添加编号标签

Quick Start

快速开始

Step 1: Run Generation

步骤1:运行生成命令

bash
undefined
bash
undefined

Text-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
undefined
scripts/generate_image.py "宁静的日落湖面" --output /generated_images/lake.png
undefined

API Configuration

API配置

ParameterValueDescription
Endpoint
https://visual.volcengineapi.com
API base URL
Submit Action
CVSync2AsyncSubmitTask
Submit async generation task
Query Action
CVSync2AsyncGetResult
Query task result
Version
2022-08-31
API version
Service
cv
Service name for signing
Region
cn-north-1
Region for signing
req_key
jimeng_t2i_v40
Jimeng AI 4.0 model identifier
参数描述
Endpoint
https://visual.volcengineapi.com
API基础地址
Submit Action
CVSync2AsyncSubmitTask
提交异步生成任务
Query Action
CVSync2AsyncGetResult
查询任务结果
Version
2022-08-31
API版本
Service
cv
签名用服务名称
Region
cn-north-1
签名用区域
req_key
jimeng_t2i_v40
即梦AI 4.0模型标识符

Image Size Options

图像尺寸选项

Preset Resolutions

预设分辨率

PresetResolutionPixels
1K1024×10241,048,576
2K2048×20484,194,304 (default)
4K4096×409616,777,216
预设值分辨率像素数
1K1024×10241,048,576
2K2048×20484,194,304(默认)
4K4096×409616,777,216

Exact Dimensions

自定义精确尺寸

Use
--width
and
--height
together:
bash
scripts/generate_image.py "prompt" --width 2560 --height 1440
Recommended 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
--height
参数:
bash
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:
  1. Build canonical request with headers:
    content-type;host;x-content-sha256;x-date
  2. Calculate SHA256 hash of canonical request
  3. Derive signing key: secret_key → date → region → service → "request"
  4. Sign the string-to-sign with derived key
  5. Add
    Authorization
    header to request
Reference: HTTP请求示例
本Skill使用火山引擎IAM v4签名认证(HMAC-SHA256)。签名流程如下:
  1. 构建包含以下头部的规范请求:
    content-type;host;x-content-sha256;x-date
  2. 计算规范请求的SHA256哈希值
  3. 派生签名密钥:secret_key → 日期 → 区域 → 服务 → "request"
  4. 使用派生密钥对待签名字符串进行签名
  5. 在请求中添加
    Authorization
    头部

Error Codes

错误码

CodeMessageDescription
10000SuccessRequest successful
50411Pre Img Risk Not PassInput image failed content check
50511Post Img Risk Not PassOutput image failed content check
50412Text Risk Not PassInput text failed content check
50413Post Text Risk Not PassInput text contains sensitive words
50429Request Has Reached API LimitRate limit exceeded, retry later
50500Internal ErrorServer error
timeoutRequest timeoutIncrease JIMENG_API_TIMEOUT
代码消息描述
10000Success请求成功
50411Pre Img Risk Not Pass输入图像未通过内容审核
50511Post Img Risk Not Pass输出图像未通过内容审核
50412Text Risk Not Pass输入文本未通过内容审核
50413Post Text Risk Not Pass输入文本包含敏感词汇
50429Request Has Reached API Limit超出API调用限制,请稍后重试
50500Internal Error服务器内部错误
timeoutRequest 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小时

Reference Documentation

参考文档