giggle-generation-image

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Giggle Image Generation (Multi-Model)

Giggle 图像生成(多模型)

Generates AI images via giggle.pro's Generation API. Supports multiple models (Seedream, Midjourney, Nano Banana). Submit task → query when ready. No polling or Cron.
API Key: Set system environment variable
GIGGLE_API_KEY
. The script will prompt if not configured.
No inline Python: All commands must be executed via the
exec
tool. Never use
python3 << 'EOF'
or heredoc inline code.
No Retry on Error: If script execution encounters an error, do not retry. Report the error to the user directly and stop.
通过giggle.pro的生成API生成AI图像。支持多种模型(Seedream、Midjourney、Nano Banana)。提交任务→准备就绪后查询。无需轮询或Cron任务。
API Key:设置系统环境变量
GIGGLE_API_KEY
。如果未配置,脚本会提示用户。
禁止内嵌Python代码:所有命令必须通过
exec
工具执行。绝对不要使用
python3 << 'EOF'
或 heredoc 内嵌代码。
错误时请勿重试:如果脚本执行遇到错误,不要重试。直接向用户报告错误并停止操作。

Supported Models

支持的模型

ModelDescription
seedream45Seedream, realistic and creative
midjourneyMidjourney style
nano-banana-2Nano Banana 2
nano-banana-2-fastNano Banana 2 fast

模型描述
seedream45Seedream,写实且富有创意
midjourneyMidjourney风格
nano-banana-2Nano Banana 2
nano-banana-2-fastNano Banana 2 快速版

Execution Flow: Submit and Query

执行流程:提交与查询

Image generation is asynchronous (typically 30–120 seconds). Submit a task to get
task_id
, then query when the user wants to check status.
Important: Never pass
GIGGLE_API_KEY
in exec's
env
parameter. API Key is read from system environment variable.

图像生成为异步操作(通常耗时30–120秒)。提交任务以获取
task_id
,然后在用户想要查看状态时进行查询
重要提示绝对不要在exec的
env
参数中传递
GIGGLE_API_KEY
。API Key会从系统环境变量中读取。

Step 1: Submit Task

步骤1:提交任务

bash
undefined
bash
undefined

Text-to-image (default seedream45)

文本生成图像(默认使用seedream45)

python3 scripts/generation_api.py
--prompt "description" --aspect-ratio 16:9
--model seedream45 --resolution 2K
--no-wait --json
python3 scripts/generation_api.py
--prompt "描述内容" --aspect-ratio 16:9
--model seedream45 --resolution 2K
--no-wait --json

Text-to-image - Midjourney

文本生成图像 - 使用Midjourney模型

python3 scripts/generation_api.py
--prompt "description" --model midjourney
--aspect-ratio 16:9 --resolution 2K
--no-wait --json
python3 scripts/generation_api.py
--prompt "描述内容" --model midjourney
--aspect-ratio 16:9 --resolution 2K
--no-wait --json

Image-to-image - Reference URL

图像生成图像 - 使用参考URL

python3 scripts/generation_api.py
--prompt "Convert to oil painting style, keep composition"
--reference-images "https://example.com/photo.jpg"
--model nano-banana-2-fast
--no-wait --json
python3 scripts/generation_api.py
--prompt "转换为油画风格,保留构图"
--reference-images "https://example.com/photo.jpg"
--model nano-banana-2-fast
--no-wait --json

Batch generate multiple images

批量生成多张图像

python3 scripts/generation_api.py
--prompt "description" --generate-count 4
--no-wait --json

Response example:
```json
{"status": "started", "task_id": "xxx"}
Store task_id in memory (
addMemory
):
giggle-generation-image task_id: xxx (submitted: YYYY-MM-DD HH:mm)
Tell the user: "Image generation started. It usually takes 30–120 seconds. You can ask me 'is it ready?' to check the status."

python3 scripts/generation_api.py
--prompt "描述内容" --generate-count 4
--no-wait --json

响应示例:
```json
{"status": "started", "task_id": "xxx"}
将task_id存储到内存(使用
addMemory
):
giggle-generation-image task_id: xxx (submitted: YYYY-MM-DD HH:mm)
告知用户:"图像生成已启动。通常需要30–120秒完成。你可以问我‘好了吗?’来查看状态。"

Step 2: Query Task (when user asks for status)

步骤2:查询任务(当用户询问状态时)

bash
python3 scripts/generation_api.py --query --task-id <task_id>
Behavior:
  • completed: Output image links for user
  • failed/error: Output error message
  • processing/pending: Output JSON
    {"status": "...", "task_id": "xxx"}
    ; user can query again later

bash
python3 scripts/generation_api.py --query --task-id <task_id>
行为说明
  • completed(已完成):向用户输出图像链接
  • failed/error(失败/错误):输出错误信息
  • processing/pending(处理中/待处理):输出JSON
    {"status": "...", "task_id": "xxx"}
    ;用户可稍后再次查询

New Request vs Query Old Task

新请求与查询旧任务

When the user initiates a new image generation request, run submit to create a new task. Do not reuse old task_id from memory.
When the user asks about a previous task's progress (e.g. "is it ready?", "check status"), query the task_id from memory.

当用户发起新的图像生成请求时,运行提交命令创建新任务。不要复用内存中的旧task_id。
当用户询问之前任务的进度时(例如“好了吗?”、“查看状态”),从内存中取出对应的task_id进行查询。

Parameter Reference

参数参考

ParameterDefaultDescription
--prompt
requiredImage description prompt
--model
seedream45seedream45, midjourney, nano-banana-2, nano-banana-2-fast
--aspect-ratio
16:916:9, 9:16, 1:1, 3:4, 4:3, 2:3, 3:2, 21:9
--resolution
2KText-to-image: 1K, 2K, 4K (image-to-image partially supported)
--generate-count
1Number of images to generate
--reference-images
-Image-to-image reference; supports URL, base64, asset_id
--watermark
falseAdd watermark (image-to-image)

参数默认值描述
--prompt
必填图像描述提示词
--model
seedream45可选模型:seedream45、midjourney、nano-banana-2、nano-banana-2-fast
--aspect-ratio
16:9可选宽高比:16:9、9:16、1:1、3:4、4:3、2:3、3:2、21:9
--resolution
2K文本生成图像:1K、2K、4K(图像生成图像部分支持)
--generate-count
1生成图像的数量
--reference-images
-图像生成图像的参考图;支持URL、base64、asset_id
--watermark
false添加水印(仅图像生成图像支持)

Image-to-Image Reference: Three Input Methods

图像生成图像参考:三种输入方式

The image-to-image API's
reference_images
is an array of objects. Each element can be one of these three formats (can be mixed):
图像生成图像API的
reference_images
是一个对象数组。每个元素可以是以下三种格式之一(可混合使用):

Method 1: URL

方式1:URL

json
{
  "prompt": "A cute orange cat sitting on the windowsill in the sun, realistic style",
  "reference_images": [
    {
      "url": "https://assets.giggle.pro/private/example/image.jpg?Policy=EXAMPLE_POLICY&Key-Pair-Id=EXAMPLE_KEY_PAIR_ID&Signature=EXAMPLE_SIGNATURE"
    }
  ],
  "generate_count": 1,
  "model": "nano-banana-2-fast",
  "aspect_ratio": "16:9",
  "watermark": false
}
json
{
  "prompt": "一只可爱的橘猫坐在阳光下的窗台上,写实风格",
  "reference_images": [
    {
      "url": "https://assets.giggle.pro/private/example/image.jpg?Policy=EXAMPLE_POLICY&Key-Pair-Id=EXAMPLE_KEY_PAIR_ID&Signature=EXAMPLE_SIGNATURE"
    }
  ],
  "generate_count": 1,
  "model": "nano-banana-2-fast",
  "aspect_ratio": "16:9",
  "watermark": false
}

Method 2: Base64

方式2:Base64

json
{
  "prompt": "A cute orange cat sitting on the windowsill in the sun, realistic style",
  "reference_images": [
    {
      "base64": "iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mP8z8BQDwAEhQGAhKmMIQAAAABJRU5ErkJggg=="
    }
  ],
  "generate_count": 1,
  "model": "nano-banana-2-fast",
  "aspect_ratio": "16:9",
  "watermark": false
}
Base64 format: Pass the raw Base64 string directly. Do not add the
data:image/xxx;base64,
prefix.
json
{
  "prompt": "一只可爱的橘猫坐在阳光下的窗台上,写实风格",
  "reference_images": [
    {
      "base64": "iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mP8z8BQDwAEhQGAhKmMIQAAAABJRU5ErkJggg=="
    }
  ],
  "generate_count": 1,
  "model": "nano-banana-2-fast",
  "aspect_ratio": "16:9",
  "watermark": false
}
Base64格式要求:直接传递原始Base64字符串。不要添加
data:image/xxx;base64,
前缀。

Method 3: asset_id

方式3:asset_id

json
{
  "prompt": "A cute orange cat sitting on the windowsill in the sun, realistic style",
  "reference_images": [
    {
      "asset_id": "vvsdsfsdf"
    }
  ],
  "generate_count": 1,
  "model": "nano-banana-2-fast",
  "aspect_ratio": "16:9",
  "watermark": false
}
For multiple reference images, add more objects to the
reference_images
array.

json
{
  "prompt": "一只可爱的橘猫坐在阳光下的窗台上,写实风格",
  "reference_images": [
    {
      "asset_id": "vvsdsfsdf"
    }
  ],
  "generate_count": 1,
  "model": "nano-banana-2-fast",
  "aspect_ratio": "16:9",
  "watermark": false
}
若要使用多张参考图,可在
reference_images
数组中添加更多对象。

Interaction Guide

交互指南

When the user request is vague, guide per the steps below. If the user has provided enough info, run the command directly.
当用户的请求模糊时,按照以下步骤引导用户。如果用户已提供足够信息,直接运行命令即可。

Step 1: Model Selection

步骤1:模型选择

Question: "Which model would you like to use?"
Title: "Image Model"
Options:
- "seedream45 - Realistic & creative (recommended)"
- "midjourney - Artistic style"
- "nano-banana-2 - High quality"
- "nano-banana-2-fast - Fast generation"
multiSelect: false
问题:"你想要使用哪种模型?"
标题:"图像模型"
选项:
- "seedream45 - 写实且富有创意(推荐)"
- "midjourney - 艺术风格"
- "nano-banana-2 - 高质量"
- "nano-banana-2-fast - 快速生成"
multiSelect: false

Step 2: Aspect Ratio

步骤2:宽高比选择

Question: "What aspect ratio do you need?"
Title: "Aspect Ratio"
Options:
- "16:9 - Landscape (wallpaper/cover) (recommended)"
- "9:16 - Portrait (mobile)"
- "1:1 - Square"
- "Other ratios"
multiSelect: false
问题:"你需要什么宽高比?"
标题:"宽高比"
选项:
- "16:9 - 横版(壁纸/封面)(推荐)"
- "9:16 - 竖版(移动端)"
- "1:1 - 正方形"
- "其他宽高比"
multiSelect: false

Step 3: Generation Mode

步骤3:生成模式选择

Question: "Do you need reference images?"
Title: "Generation Mode"
Options:
- "No - Text-to-image only"
- "Yes - Image-to-image (style transfer)"
multiSelect: false
问题:"你需要使用参考图像吗?"
标题:"生成模式"
选项:
- "不需要 - 仅文本生成图像"
- "需要 - 图像生成图像(风格迁移)"
multiSelect: false

Step 4: Execute and Display

步骤4:执行与展示

Submit task → store task_id → inform user. When user asks for status, run query and forward stdout to user.
Link return rule: Image links in results must be full signed URLs (with Policy, Key-Pair-Id, Signature query params). Correct:
https://assets.giggle.pro/...?Policy=...&Key-Pair-Id=...&Signature=...
. Wrong: do not return unsigned URLs with only the base path (no query params).
提交任务→存储task_id→告知用户。当用户询问状态时,运行查询命令并将标准输出转发给用户。
链接返回规则:结果中的图像链接必须是完整的签名URL(包含Policy、Key-Pair-Id、Signature查询参数)。正确示例:
https://assets.giggle.pro/...?Policy=...&Key-Pair-Id=...&Signature=...
。错误示例:不要返回仅包含基础路径的未签名URL(无查询参数)。