SuperAPI AI Directory

hy-image-generation

Design & creation

View repository

Updated 10-26 20:31

About this skill

Tencent Cloud Hunyuan Image Generation Skill

Feature Description

This Skill providesHunyuan Image Generationcapabilities. Based on the Tencent Hunyuan large model, it quickly generates AI images from text descriptions. It supports reference-image guidance, custom resolution, and prompt rewriting and optimization.

Scenario Script Description
One-stop image generation main.py Submit task + automatic polling, recommended
Submit task only submit_job.py Submit only, returns JobId
Query task only query_job.py Query/poll results by JobId

🎯 Selection Rules

用户要求生成图片  →  main.py(一站式,最简单推荐)
用户要求提交后自行查询  →  submit_job.py + query_job.py(分步操作)
用户已有 JobId 要查结果  →  query_job.py(单独查询)

If the user does not specify which mode to use, the Agent should use main.py the one-stop script by default.

Supported Features

  • Reference-image guidance: supports passing in up to 3 reference image URLs to guide the image generation direction
  • Custom resolution: width and height within the range [512, 2048], with an area not exceeding 1024×1024
  • Prompt rewriting: enabled by default, automatically optimizes the prompt for better results (adds about 20s)
  • Reproducible generation: supports a fixed random seed via Seed
  • Automatic dependency installation: automatically installs the required SDK on first run
  • Intelligent credential detection: preferentially obtains the key from environment variables, and prompts the user to activate the service when not configured

Environment Configuration Guide

Key Configuration

This Skill requires a Tencent Cloud API key to work properly.

Step 1: Activate the Hunyuan Image Generation service

🔗 Tencent Cloud Intelligent Image Creation Console

Step 2: Obtain an API key

🔗 Tencent Cloud API Key Management

Step 3: Set environment variables

Linux / macOS:

export TENCENTCLOUD_SECRET_ID="你的SecretId"
export TENCENTCLOUD_SECRET_KEY="你的SecretKey"

To persist:

echo 'export TENCENTCLOUD_SECRET_ID="你的SecretId"' >> ~/.zshrc
echo 'export TENCENTCLOUD_SECRET_KEY="你的SecretKey"' >> ~/.zshrc
source ~/.zshrc

Windows (PowerShell):

$env:TENCENTCLOUD_SECRET_ID = "你的SecretId"
$env:TENCENTCLOUD_SECRET_KEY = "你的SecretKey"

⚠️ Security note: never hardcode keys in code.

Agent Execution Instructions (Required Reading)

⚠️ This section is the core execution specification for the Agent (AI model). When the user requests image generation, the Agent must strictly and autonomously execute the following steps without asking the user for confirmation.

🔑 General Execution Rules

  1. Trigger condition: the user has provided a text description and the intent is to generate an AI image.
  2. Zero-interaction principle: the Agent should execute the script directly and not ask the user for any confirmation.
  3. Automatic script selection: use main.py(one-stop) by default, unless the user explicitly requests step-by-step operation.
  4. ⛔ Using the large model's own capabilities to replace image generation is prohibited (highest-priority rule):
    • The Agent is strictly prohibited from fabricating image URLs or describing generated results on its own.
    • If the call fails, the Agent mustreturn a clear error explanation to the user.

📌 Script 1: One-stop image generation main.py(recommended)

Applicable scenario: the user requests image generation; automatically submits and waits for the result

python3 <SKILL_DIR>/scripts/main.py "文本描述"

Optional parameters:

  • --images <URL1> <URL2> ...: List of reference image URLs, up to 3 (jpg/jpeg/png/webp, ≤ 10MB after base64)
  • --resolution <W:H>: Resolution, default 1024:1024. Width and height in [512, 2048], area ≤ 1024×1024
  • --seed <N>: Random seed (positive integer, random if not passed)
  • --revise <0|1>: Prompt rewriting, enabled by default (1). Disabled (0) requires rewriting the prompt yourself, otherwise affects results. Rewriting adds about 20s
  • --no-poll: Submit the task only without waiting for the result (returns JobId)

Output example:

{
  "job_id": "job-xxxxxxxxxxxx",
  "status": "success",
  "result_image": "https://aiart-xxx.cos.ap-guangzhou.myqcloud.com/xxx.png",
  "result_details": ["https://aiart-xxx.cos.ap-guangzhou.myqcloud.com/xxx.png"],
  "revised_prompt": "一只可爱的橘色猫咪在充满鲜花的花园里愉快地玩耍,阳光明媚,色彩鲜艳"
}

Note: Generated image URL is valid for 1 hour, please save it promptly. Normal image generation usually takes 10~30 seconds; enabling Revise adds about 20s.


📌 Script 2: Submit task only submit_job.py

Use case: Only need to submit a task to get a JobId, then query manually later

python3 <SKILL_DIR>/scripts/submit_job.py "文本描述"

Optional parameters: Same as main.py (except --poll-interval、--max-poll-time、--no-poll )

Output example:

{
  "job_id": "job-xxxxxxxxxxxx",
  "request_id": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
  "message": "Task submitted successfully. Use query_job.py to poll for results."
}

📌 Script 3: Query task query_job.py

Use case: Query task status and results by JobId

python3 <SKILL_DIR>/scripts/query_job.py "job-xxxxxxxxxxxx"

Optional parameters:

  • --poll-interval <N>: Polling interval in seconds, default 5
  • --max-poll-time <N>: Maximum polling time in seconds, default 300
  • --no-poll: Query only once, no polling

Output example:

{
  "job_id": "job-xxxxxxxxxxxx",
  "status": "success",
  "result_image": "https://aiart-xxx.cos.ap-guangzhou.myqcloud.com/xxx.png",
  "result_details": ["https://aiart-xxx.cos.ap-guangzhou.myqcloud.com/xxx.png"],
  "revised_prompt": "优化后的提示词内容"
}

📋 Complete call example

# 基础生图
python3 /path/to/scripts/main.py "一只可爱的猫咪在花园里玩耍"

# 带垫图引导的生图
python3 /path/to/scripts/main.py --images "https://example.com/ref1.jpg" "https://example.com/ref2.png" "参考这些图片风格,画一幅山水画"

# 自定义分辨率(横版)
python3 /path/to/scripts/main.py --resolution 1024:768 "壮丽的山水画"

# 固定种子(可复现)
python3 /path/to/scripts/main.py --seed 42 "星空下的城堡"

# 关闭 prompt 改写(不推荐,除非自行改写 prompt)
python3 /path/to/scripts/main.py --revise 0 "详细描述的prompt内容..."

# 仅提交任务
python3 /path/to/scripts/main.py --no-poll "一幅水墨画"

# 查询已有任务
python3 /path/to/scripts/query_job.py "job-xxxxxxxxxxxx"

# 通过 stdin 传入 JSON 参数
echo '{"prompt":"一只猫","images":["https://xxx.jpg"],"resolution":"1024:1024"}' | python3 /path/to/scripts/main.py --stdin

📐 Resolution description

Constraint Description
Width range [512, 2048] pixels
Height range [512, 2048] pixels
Area upper limit Width × Height ≤ 1024 × 1024 = 1,048,576 pixels
Default value 1024:1024

Common combinations:

Resolution Aspect ratio Description
1024:1024 1:1 Default square image
768:1024 3:4 Portrait
1024:768 4:3 Landscape
512:1024 1:2 Portrait long image
1024:512 2:1 Landscape long image

🖼️ Reference images (Images) description

  • Pass in a list of reference image URLs to guide the image generation direction
  • Up to 3 images
  • Supported formats:jpg、jpeg、png、webp
  • Each image must not exceed 10MB

❌ Behaviors the Agent must avoid

  • Only printing the script path without executing it
  • Asking the user "whether to execute image generation" — should execute directly
  • Manually installing dependencies — the script handles this automatically
  • Forgetting to read the result_image URL in the output result and return it to the user
  • Fabricating an image URL when image generation fails
  • Forgetting to remind the user that the image URL is valid for 1 hour

API reference documentation

For detailed parameter descriptions, error codes, etc., please refer to the documents in the references/ directory:

Core scripts

  • scripts/main.py — All-in-one image generation: submit task + automatically poll for results
  • scripts/submit_job.py — Submit image generation task only, returns JobId
  • scripts/query_job.py — Query/poll task status and results by JobId

Dependencies

  • Python 3.7+
  • tencentcloud-sdk-python(Tencent Cloud SDK)

Install dependencies (optional - the script will install automatically):

pip install tencentcloud-sdk-python