ERNIE Image Generation

v1.0.0

Generate images using Baidu AI Studio's ERNIE-Image and ERNIE-Image-Turbo models via the OpenAI-compatible API. Supports text-to-image generation with 7 size...

0· 25· 1 versions· 0 current· 0 all-time· Updated 6h ago· MIT-0

Install

openclaw skills install ernie-image-gen

ERNIE-Image Generation

Generate images using Baidu AI Studio's ERNIE-Image models through the OpenAI-compatible API. Two models are available:

  • ERNIE-Image-Turbo (default): Fast generation, excellent for most use cases
  • ERNIE-Image: Higher quality, slower generation for when detail matters

Both models understand Chinese prompts particularly well.

Prerequisites

Generation Workflow

Step 1 -- Compose the prompt

Write a descriptive prompt (max 1024 characters, ~150 words). Chinese and English both work well. Be specific about subject, style, composition, and mood.

Good: "A golden retriever puppy sitting in a sunflower field at sunset, warm golden light, shallow depth of field, professional photography" Bad: "dog"

Step 2 -- Choose parameters

ParameterValuesDefault
modelERNIE-Image-Turbo, ERNIE-ImageERNIE-Image-Turbo
size1024x1024, 768x1376, 1376x768, 896x1200, 1200x896, 848x1264, 1264x8481024x1024
n1-41
seedany integerrandom
steps4-208
guidance1.0-7.51.0
use-peflagoff

Select size based on content: portraits and posters use vertical (768x1376, 848x1264, 896x1200), landscapes and covers use horizontal (1376x768, 1264x848, 1200x896), general use 1024x1024.

Step 3 -- Run the generation script

Execute the bundled script with uv run:

uv run {baseDir}/scripts/generate.py "<PROMPT>" --model ERNIE-Image-Turbo --size 1024x1024

For batch generation:

uv run {baseDir}/scripts/generate.py "<PROMPT>" --n 4 --output ./output_dir

For higher quality with more inference steps and stronger guidance:

uv run {baseDir}/scripts/generate.py "<PROMPT>" --model ERNIE-Image --steps 16 --guidance 3.5

For reproducible results:

uv run {baseDir}/scripts/generate.py "<PROMPT>" --seed 42

Step 4 -- Output

The script saves images as PNG files to the output directory and prints:

Saved: ernie_20260430_110100.png (1.7 MB)
MEDIA:/absolute/path/to/ernie_20260430_110100.png

The MEDIA: line enables automatic image attachment in compatible environments.

For JSON output, add --json to get structured results:

{
  "success": true,
  "model": "ERNIE-Image-Turbo",
  "files": [{"path": "/abs/path/ernie_20260430_110100.png", "size_bytes": 1715660}],
  "prompt": "...",
  "parameters": {"size": "1024x1024", "seed": 42}
}

Quick Triggers

When the user says any of these, treat the text after the trigger as the prompt and generate immediately with defaults:

  • Chinese: "生成图片:xxx" / "文生图:xxx" / "百度生图:xxx" / "ERNIE生图:xxx"
  • English: "generate image: xxx" / "ernie image: xxx" / "baidu image: xxx"

Defaults: model=ERNIE-Image-Turbo, size=1024x1024, n=1, b64_json format.

Notes

  • Images are saved locally as PNG files with MEDIA:<path> for auto-attach.
  • Chinese prompts work particularly well with ERNIE models.
  • Prompt enhancement (--use-pe) lets the model expand simple prompts into richer descriptions before generation. Enable for short prompts, disable for precise control.
  • For full API reference, model comparison, all size options, parameter details, and troubleshooting, read {baseDir}/references/api-guide.md.

Version tags

latestvk97f5qpwmv5wf2yc5fhjypwzv185vqxm

Runtime requirements

🎨 Clawdis
EnvAI_STUDIO_API_KEY
Primary envAI_STUDIO_API_KEY