IMA Image AI Creation
💬 User Experience Protocol (IM / Feishu / Discord) v1.3 🆕
CRITICAL FIX in v1.2: Added Step 0 to ensure correct message ordering in group chats.
NEW in v1.3: Added original image URL in Step 3 caption for easy copying/sharing.
v1.1 Bug: Confirmation message ("好的!来帮你画...") appeared LAST because it used NO_REPLY.
v1.2 Fix: Always reply with confirmation FIRST (Step 0), then push updates via message tool.
v1.3 Enhancement: Include 🔗 原始链接:[url] in success caption so users can copy/share the URL.
This skill runs inside IM platforms (Feishu, Discord via OpenClaw).
Never let users wait in silence. Always follow all 6 steps below, every single time.
🚫 Never Say to Users
| ❌ Never say |
✅ What users care about |
ima_image_create.py / 脚本 / script |
— |
| 自动化脚本 / automation |
— |
| 自动处理产品列表 / 查询接口 |
— |
| 自动解析参数 / 智能轮询 |
— |
| attribute_id / model_version / form_config |
— |
| API 调用 / HTTP 请求 / 任何技术参数名 |
— |
Only tell users: model name · estimated time · credits · result (image/media) · plain-language status.
Estimated Generation Time per Model
| Model |
Estimated Time |
Poll Every |
Send Progress Every |
| SeeDream 4.5 🌟 |
30~60s |
5s |
20s |
| Nano Banana2 💚 |
20~40s |
5s |
15s |
| Nano Banana Pro |
60~120s |
5s |
30s |
| Midjourney 🎨 |
40~90s |
8s |
25s |
estimated_max_seconds = the upper bound of the range above (e.g. 60 for SeeDream 4.5, 120 for Nano Banana Pro, 90 for Midjourney).
Step 0 — Initial Acknowledgment Reply (Normal Reply) 🆕
⚠️ CRITICAL: This step is NEW in v1.2 and fixes the message ordering bug.
Before doing anything else, reply to the user with a friendly acknowledgment message using your normal reply (not message tool). This reply will automatically appear FIRST in the conversation.
Example acknowledgment messages:
好的!来帮你画一只萌萌的猫咪 🐱
收到!马上为你生成一张 16:9 的风景照 🏔️
OK! Starting image generation with SeeDream 4.5 🎨
Rules:
- Keep it short and warm (< 15 words)
- Match the user's language (Chinese/English)
- Include relevant emoji (🐱/🎨/✨)
- This is your ONLY normal reply — all subsequent updates use
message tool
Why this matters:
- Normal replies automatically appear FIRST in the conversation thread
message tool pushes appear in chronological order AFTER your initial reply
- This ensures users see: "好的!" → "🎨 开始生成..." → "✅ 成功!" (correct order)
Step 1 — Pre-Generation Notification (Push via message tool)
After Step 0 reply, use the message tool to push a notification immediately to the group/channel:
# Agent implementation
message(
action="send",
target=group_id, # or channel_id for Discord
message="""🎨 开始生成图片,请稍候…
• 模型:[Model Name]
• 预计耗时:[X ~ Y 秒]
• 消耗积分:[N pts]"""
)
User-facing message template:
🎨 开始生成图片,请稍候…
• 模型:[Model Name]
• 预计耗时:[X ~ Y 秒]
• 消耗积分:[N pts]
Cost transparency examples:
- Balanced/default (5-6 pts): "使用 SeeDream 4.5(5 积分,性价比最佳)"
- Premium (>10 pts): "使用 Nano Banana Pro(10-18 积分,最高质量,支持 1K/2K/4K)"
- Budget (user explicit): "使用 Nano Banana2(4 积分,最便宜最快)"
Adapt language to match the user. Chinese → 🎨 开始生成图片,请稍候… / English → 🎨 Starting image generation, please wait…
Step 2 — Progress Updates (Push via message tool)
Implementation:
- Start the generation script in background or use polling loop
- Track elapsed time since start
- Every
[Send Progress Every] seconds (from table above), push a progress update via message tool
- Stop when task completes (success/failure)
Progress message template:
⏳ 正在生成中… [P]%
已等待 [elapsed]s,预计最长 [max]s
Progress formula:
P = min(95, floor(elapsed_seconds / estimated_max_seconds * 100))
Rules:
- Cap at 95% — never show 100% until the API returns
success
- If
elapsed > estimated_max: keep P at 95% and append 「稍等,即将完成…」
- Example: elapsed=40s, max=60s → P = min(95, floor(40/60*100)) = min(95, 66) = 66%
When to send progress:
- Short tasks (<20s): No progress needed, skip Step 2
- Medium tasks (20-60s): Send 1-2 updates
- Long tasks (>60s): Send updates every 20-30s
Step 3 — Success Notification (Push image via message tool)
When task status = success, use the message tool to send the generated image directly (not as a text URL):
Agent implementation:
# Get result URL from script output or task detail API
result = get_task_result(task_id)
image_url = result["medias"][0]["url"]
# Push image + caption to group/channel
message(
action="send",
target=group_id,
media=image_url, # Feishu/Discord will render the image
caption="""✅ 图片生成成功!
• 模型:[Model Name]
• 耗时:预计 [X~Y]s,实际 [actual]s
• 消耗积分:[N pts]
🔗 原始链接:[image_url]"""
)
User-facing message:
✅ 图片生成成功!
• 模型:[Model Name]
• 耗时:预计 [X~Y]s,实际 [actual]s
• 消耗积分:[N pts]
🔗 原始链接:https://...
[图片直接显示在上方]
Platform-specific notes:
- Feishu:
message(action=send, media=url, caption="...") — caption appears below image
- Discord: Image embeds automatically from URL; caption can be in message text
- Telegram: Use
message(action=send, media=url, caption="...")
⚠️ Important: Do NOT send plain text URL like https://cdn.../image.jpg. Users expect to see the actual image rendered.
Step 4 — Failure Notification (Push via message tool)
When task status = failed or any API/network error, push a failure message with alternative suggestions:
Agent implementation:
message(
action="send",
target=group_id,
message="""❌ 图片生成失败
• 原因:[natural_language_error_message]
• 建议改用:
- [Alt Model 1]([特点],[N pts])
- [Alt Model 2]([特点],[N pts])
需要我帮你用其他模型重试吗?"""
)
⚠️ CRITICAL: Error Message Translation
NEVER show technical error messages to users. Always translate API errors into natural language:
| Technical Error |
❌ Never Say |
✅ Say Instead (Chinese) |
✅ Say Instead (English) |
"Invalid product attribute" / "Insufficient points" |
Invalid product attribute |
生成参数配置异常,请稍后重试 |
Configuration error, please try again later |
Error 6006 (credit mismatch) |
Error 6006 |
积分计算异常,系统正在修复 |
Points calculation error, system is fixing |
Error 6010 (attribute_id mismatch) |
Attribute ID does not match |
模型参数不匹配,请尝试其他模型 |
Model parameters incompatible, try another model |
error 400 (bad request, e.g. invalid size) |
error 400 / Bad request |
图片参数设置有误,请调整尺寸或比例 |
Image parameter error, adjust size or aspect ratio |
resource_status == 2 |
Resource status 2 / Failed |
图片生成遇到问题,建议换个模型试试 |
Image generation failed, try another model |
status == "failed" (no details) |
Task failed |
这次生成没成功,要不换个模型试试? |
Generation unsuccessful, try a different model? |
timeout |
Task timed out / Timeout error |
生成时间过长已超时,建议用更快的模型 |
Generation took too long, try a faster model |
| Network error / Connection refused |
Connection refused / Network error |
网络连接不稳定,请检查网络后重试 |
Network connection unstable, check network and retry |
| API key invalid |
Invalid API key / 401 Unauthorized |
API 密钥无效,请联系管理员 |
API key invalid, contact administrator |
| Rate limit exceeded |
429 Too Many Requests / Rate limit |
请求过于频繁,请稍等片刻再试 |
Too many requests, please wait a moment |
| Model unavailable |
Model not available / 503 Service Unavailable |
当前模型暂时不可用,建议换个模型 |
Model temporarily unavailable, try another model |
| Unsupported aspect ratio (Nano Banana Pro) |
Parameter not supported |
该模型不支持自定义比例,推荐使用 SeeDream 4.5 |
This model doesn't support custom aspect ratios, try SeeDream 4.5 |
Generic fallback (when error is unknown):
- Chinese:
图片生成遇到问题,请稍后重试或换个模型试试
- English:
Image generation encountered an issue, please try again or use another model
Best Practices:
- Focus on user action: Tell users what to do next, not what went wrong technically
- Be reassuring: Use phrases like "建议换个模型试试" instead of "生成失败了"
- Avoid blame: Never say "你的参数有问题" → say "参数需要调整一下"
- Provide alternatives: Always suggest 1-2 alternative models in the failure message
- Image-specific: For aspect ratio errors, recommend SeeDream 4.5 (supports custom ratios)
Failure fallback table:
| Failed Model |
First Alt |
Second Alt |
| SeeDream 4.5 |
Nano Banana2(4pts,快速便宜) |
Nano Banana Pro(10-18pts,高质量) |
| Nano Banana2 |
SeeDream 4.5(5pts,更高质量) |
Nano Banana Pro(10-18pts) |
| Nano Banana Pro |
SeeDream 4.5(5pts,性价比高) |
Nano Banana2(4pts,最便宜) |
| Any / Unknown |
SeeDream 4.5(5pts,默认首选) |
Nano Banana2(4pts,预算紧张) |
Step 5 — Done (No Further Action Needed) 🆕
v1.2 Change: Step 5 is now simplified.
After completing Steps 0-4:
- ✅ Step 0 already sent your normal reply (appears FIRST in chat)
- ✅ Steps 1-4 pushed all updates via
message tool (appear in order)
- ✅ No further action needed — conversation is complete
Do NOT:
- ❌ Reply again with
NO_REPLY (you already replied in Step 0)
- ❌ Send duplicate confirmation messages
- ❌ Use
message tool to send the same content twice
Why this works:
User: "帮我画一只猫"
↓
[Step 0] Your normal reply: "好的!来帮你画一只萌萌的猫咪 🐱" ← Appears FIRST
↓
[Step 1] message tool push: "🎨 开始生成图片..." ← Appears SECOND
↓
[Step 2] message tool push: "⏳ 正在生成中… 45%" ← (if task takes >20s)
↓
[Step 3] message tool push: "✅ 图片生成成功! [图片]" ← Appears LAST
↓
[Step 5] Done. No further replies.
🎯 Summary: What Changed in v1.2 & v1.3
| Version |
Step |
Change |
| v1.2 |
Step 0 |
✅ NEW: Normal reply with acknowledgment (appears FIRST) |
| v1.2 |
Step 1 |
Use message tool for notification only (not all messages) |
| v1.2 |
Step 5 |
✅ FIXED: No further action (already replied in Step 0), no NO_REPLY |
| v1.3 |
Step 3 |
✅ NEW: Added 🔗 原始链接:[url] in caption for easy copying |
Root cause of v1.1 bug:
- v1.1 used
message tool for ALL messages (including acknowledgment)
- Then replied
NO_REPLY to suppress normal reply
- Result: Acknowledgment appeared LAST (because
message tool pushes are chronological)
v1.2 fix:
- Step 0 uses normal reply (automatically appears FIRST)
- Steps 1-4 use
message tool (appear in chronological order)
- No
NO_REPLY needed (already replied in Step 0)
v1.3 enhancement:
- Step 3 caption now includes original image URL
- Users can easily copy/share the link without asking
Complete Example: Correct v1.2 Flow
# User: "帮我画一只可爱的猫咪"
# Step 0: Normal reply (appears FIRST in chat)
# Agent's normal response mechanism automatically handles this
reply_text = "好的!来帮你画一只萌萌的猫咪 🐱"
# (This is your normal LLM response, not a tool call)
# Step 1: Push start notification
message(
action="send",
target="oc_b30b266d43b69674e3ad160de9d13cf2",
message="🎨 开始生成图片,请稍候…\n• 模型:SeeDream 4.5\n• 预计耗时:30~60秒\n• 消耗积分:5 pts"
)
# Background: Start generation
exec(command="python3 ima_image_create.py ...", background=True, sessionId=sid)
# Step 2: Progress updates (if task takes >20s)
# (Poll in background and push updates via message tool)
start_time = time.time()
while not done:
elapsed = int(time.time() - start_time)
if elapsed >= 20 and elapsed % 20 == 0: # Every 20s
progress = min(95, int(elapsed / 60 * 100))
message(
action="send",
target="oc_b30b266d43b69674e3ad160de9d13cf2",
message=f"⏳ 正在生成中… {progress}%\n已等待 {elapsed}s,预计最长 60s"
)
time.sleep(5) # Poll every 5s
# Step 3: Success (push image)
result = get_result(task_id)
message(
action="send",
target="oc_b30b266d43b69674e3ad160de9d13cf2",
media="https://ws.esxscloud.com/.../image.jpeg",
caption=f"✅ 图片生成成功!\n• 模型:SeeDream 4.5\n• 耗时:实际 35s\n• 消耗积分:5 pts\n\n🔗 原始链接:{result['url']}"
)
# Step 5: Done — no further action
# (Do NOT reply again, do NOT use NO_REPLY)
Result in chat (correct order):
[User] 帮我画一只可爱的猫咪
[Agent] 好的!来帮你画一只萌萌的猫咪 🐱 ← Step 0 (normal reply)
[Agent] 🎨 开始生成图片,请稍候… ← Step 1 (message tool)
• 模型:SeeDream 4.5
• 预计耗时:30~60秒
• 消耗积分:5 pts
[Agent] ⏳ 正在生成中… 66% ← Step 2 (message tool, if >20s)
已等待 40s,预计最长 60s
[Agent] ✅ 图片生成成功! ← Step 3 (message tool)
• 模型:SeeDream 4.5
• 耗时:实际 35s
• 消耗积分:5 pts
🔗 原始链接:https://...
[图片]
⚙️ How This Skill Works
For transparency: This skill uses a bundled Python script (scripts/ima_image_create.py) to call the IMA Open API. The script:
- Sends your prompt to IMA's servers (two domains, see below)
- Uses
--user-id only locally as a key for storing your model preferences
- Returns an image URL when generation is complete
🌐 Network Endpoints Used
This skill connects to two domains owned by IMA Studio for complete functionality:
| Domain |
Purpose |
What's Sent |
Authentication |
api.imastudio.com |
Main API (task creation, status polling) |
Prompts, model params, task IDs |
Bearer token (IMA API key) |
imapi.liveme.com |
Image upload service (OSS token generation) |
Image files (for i2i tasks), IMA API key |
IMA API key + APP_KEY signature |
Why two domains?
api.imastudio.com: IMA's image generation API (handles task orchestration)
imapi.liveme.com: IMA's media storage infrastructure (handles large file uploads)
- Both services are owned and operated by IMA Studio
Privacy implications:
- Your IMA API key is sent to both domains for authentication
- Image files are uploaded to
imapi.liveme.com to obtain CDN URLs (for image_to_image tasks)
- Image generation happens on
api.imastudio.com using the CDN URLs
- For text_to_image tasks (no image input), only
api.imastudio.com is contacted
Security verification:
# List all network endpoints in the code:
grep -n "https://" scripts/ima_image_create.py
# Expected output:
# 60: DEFAULT_BASE_URL = "https://api.imastudio.com"
# 61: DEFAULT_IM_BASE_URL = "https://imapi.liveme.com"
If you're concerned about the two-domain architecture:
- Review IMA Studio's privacy policy at https://imastudio.com/privacy
- Contact IMA technical support to confirm domain ownership: support@imastudio.com
- Use a test/scoped API key first (see security notice below)
- Monitor network traffic during first run (instructions in SECURITY.md)
⚠️ Credential Security Notice
Your IMA API key is sent to TWO domains:
api.imastudio.com — Main image generation API
imapi.liveme.com — Image upload service (only when using image_to_image tasks)
Both domains are owned by IMA Studio, but if you're concerned about credential exposure:
✅ Best practices:
- Use a test/scoped API key for initial testing (create at https://imastudio.com/api-keys)
- Set a low quota (e.g., 100 credits) for the test key
- Rotate your key after testing if needed
- Monitor network traffic during first run (see SECURITY.md § "Network Traffic Verification")
- Contact IMA support to confirm domain ownership: support@imastudio.com
❌ Do NOT:
- Use a production key if you're uncomfortable with the two-domain architecture
- Share your API key with others
- Commit your API key to version control
What gets sent to IMA servers:
- ✅ Your image prompt/description
- ✅ Model selection (SeeDream/Nano Banana/Midjourney)
- ✅ Image parameters (size, quality, aspect ratio, etc.)
- ✅ Image files (for image_to_image tasks, uploaded to
imapi.liveme.com)
- ✅ IMA API key (for authentication to both domains)
- ❌ NO user_id (it's only used locally)
What's stored locally:
~/.openclaw/memory/ima_prefs.json - Your model preferences (< 1 KB)
~/.openclaw/logs/ima_skills/ - Generation logs (auto-deleted after 7 days)
- See SECURITY.md for complete privacy policy
Agent Execution (Internal Reference)
Note for users: You can review the script source at scripts/ima_image_create.py anytime.
The agent uses this script to simplify API calls. Network requests go to two IMA Studio domains: api.imastudio.com (API) and imapi.liveme.com (image uploads for i2i tasks).
Use the bundled script internally to ensure correct parameter construction:
# List available models
python3 {baseDir}/scripts/ima_image_create.py \
--api-key $IMA_API_KEY \
--task-type text_to_image \
--list-models
# Generate image
python3 {baseDir}/scripts/ima_image_create.py \
--api-key $IMA_API_KEY \
--task-type text_to_image \
--model-id doubao-seedream-4.5 \
--prompt "a cute puppy running on grass" \
--user-id {user_id} \
--output-json
# Image to image
python3 {baseDir}/scripts/ima_image_create.py \
--api-key $IMA_API_KEY \
--task-type image_to_image \
--model-id doubao-seedream-4.5 \
--prompt "turn into oil painting style" \
--input-images https://example.com/photo.jpg \
--user-id {user_id} \
--output-json
The script outputs JSON — parse it to get the result URL and pass it to the user via the UX protocol messages above.
Overview
Call IMA Open API to create AI-generated images. All endpoints require an ima_* API key. The core flow is: query products → create task → poll until done.
🔒 Security & Transparency Policy
This skill is community-maintained and open for inspection.
✅ What Users CAN Do
Full transparency:
- ✅ Review all source code: Check
scripts/ima_image_create.py and ima_logger.py anytime
- ✅ Verify network calls: Network requests go to two IMA Studio domains:
api.imastudio.com (API) and imapi.liveme.com (image uploads for i2i tasks). See "🌐 Network Endpoints Used" section above for full details.
- ✅ Inspect local data: View
~/.openclaw/memory/ima_prefs.json and log files
- ✅ Control privacy: Delete preferences/logs anytime, or disable file writes (see below)
Configuration allowed:
- ✅ Set API key in environment or agent config:
- Environment variable:
export IMA_API_KEY=ima_your_key_here
- OpenClaw/MCP config: Add
IMA_API_KEY to agent's environment configuration
- Get your key at: https://imastudio.com
- ✅ Use scoped/test keys: Test with limited API keys, rotate after testing
- ✅ Disable file writes: Make prefs/logs read-only or symlink to
/dev/null
Data control:
- ✅ View stored data:
cat ~/.openclaw/memory/ima_prefs.json
- ✅ Delete preferences:
rm ~/.openclaw/memory/ima_prefs.json (resets to defaults)
- ✅ Delete logs:
rm -rf ~/.openclaw/logs/ima_skills/ (auto-cleanup after 7 days anyway)
- ✅ Review security: See SECURITY.md for complete privacy policy
⚠️ Advanced Users: Fork & Modify
If you need to modify this skill for your use case:
- Fork the repository (don't modify the original)
- Update your fork with your changes
- Test thoroughly with limited API keys
- Document your changes for troubleshooting
Note: Modified skills may break API compatibility or introduce security issues. Official support only covers the unmodified version.
❌ What to AVOID (Security Risks)
Actions that could compromise security:
- ❌ Sharing API keys publicly or in skill files
- ❌ Modifying API endpoints to unknown servers
- ❌ Disabling SSL/TLS certificate verification
- ❌ Logging sensitive user data (prompts, IDs, etc.)
- ❌ Bypassing authentication or billing mechanisms
Why this matters:
- API Compatibility: Skill logic aligns with IMA Open API schema
- Security: Malicious modifications could leak credentials or bypass billing
- Support: Modified skills may not be supported
- Community: Breaking changes affect all users
📋 Privacy & Data Handling Summary
What this skill does with your data:
| Data Type |
Sent to IMA? |
Stored Locally? |
User Control |
| Image prompts |
✅ Yes (required for generation) |
❌ No |
None (required) |
| API key |
✅ Yes (authentication header) |
❌ No |
Set via env var |
| user_id (optional CLI arg) |
❌ Never (local preference key only) |
✅ Yes (as prefs file key) |
Change --user-id value |
| Model preferences |
❌ No |
✅ Yes (~/.openclaw) |
Delete anytime |
| Generation logs |
❌ No |
✅ Yes (~/.openclaw) |
Auto-cleanup 7 days |
Privacy recommendations:
- Use test/scoped API keys for initial testing
- Note:
--user-id is never sent to IMA servers - it's only used locally as a key for storing preferences in ~/.openclaw/memory/ima_prefs.json
- Review source code at
scripts/ima_image_create.py to verify network calls (search for create_task function)
- Rotate API keys after testing or if compromised
Get your IMA API key: Visit https://imastudio.com to register and get started.
🔧 For Skill Maintainers Only
Version control:
- All changes must go through Git with proper version bumps (semver)
- CHANGELOG.md must document all changes
- Production deployments require code review
File checksums (optional):
# Verify skill integrity
sha256sum SKILL.md scripts/ima_image_create.py
If users report issues, verify file integrity first.
🧠 User Preference Memory
User preferences override recommended defaults. If a user has generated before, use their preferred model — not the system default.
Storage
Preferences are stored in ~/.openclaw/memory/ima_prefs.json:
{
"user_{user_id}": {
"text_to_image": {
"model_id": "doubao-seedream-4.5",
"model_name": "SeeDream 4.5",
"credit": 5,
"last_used": "2026-02-26T03:07:27Z"
},
"image_to_image": {
"model_id": "doubao-seedream-4.5",
"model_name": "SeeDream 4.5",
"credit": 5,
"last_used": "2026-02-25T10:00:00Z"
}
}
}
If the file or key doesn't exist, fall back to the ⭐ Recommended Defaults below.
When to Read (Before Every Generation)
- Load
~/.openclaw/memory/ima_prefs.json (silently, no error if missing)
- Look up
user_{user_id}.{task_type} (e.g. user_12345.text_to_image)
- If found → use that model; mention it in the pre-generation notification:
🎨 根据你的使用习惯,将用 [Model Name] 帮你生成图片…
• 模型:[Model Name](你的常用模型)
• 预计耗时:[X ~ Y 秒]
• 消耗积分:[N pts]
- If not found → use the ⭐ Recommended Default and skip any mention of "习惯"
When to Write (After Every Successful Generation)
After task status = success, save the used model back to the preference file:
import json, os
from datetime import datetime, timezone
prefs_path = os.path.expanduser("~/.openclaw/memory/ima_prefs.json")
os.makedirs(os.path.dirname(prefs_path), exist_ok=True)
try:
with open(prefs_path) as f:
prefs = json.load(f)
except (FileNotFoundError, json.JSONDecodeError):
prefs = {}
user_key = f"user_{user_id}"
prefs.setdefault(user_key, {})[task_type] = {
"model_id": model_id,
"model_name": model_name,
"credit": credit,
"last_used": datetime.now(timezone.utc).isoformat(),
}
with open(prefs_path, "w") as f:
json.dump(prefs, f, ensure_ascii=False, indent=2)
When to Update (User Explicitly Changes Model)
Detect intent in user messages. Trigger phrases (Chinese + English):
| Trigger |
Action |
用XXX / 换成XXX / 改用XXX |
Switch to named model for this request AND save as new preference |
以后都用XXX / 默认用XXX / always use XXX |
Save as preference, confirm: ✅ 已记住!以后图片生成默认用 [XXX] |
换个模型 / try another model |
Ask user to choose; save chosen model as new preference |
用最好的 / best quality / 最强的 |
Use highest-quality model (Nano Banana Pro); save preference |
用便宜的 / cheapest |
Use lowest-cost model; do NOT save as preference unless user says "以后都用" |
Preference Confirmation Message
When switching to a different model than their preference, confirm:
💡 你之前喜欢用 [Old Model]。这次你选了 [New Model],要把它设为默认吗?
回复「是」保存 / 回复「否」仅本次使用
⭐ Recommended Defaults
These are fallback defaults — only used when no user preference exists.
Always default to the newest and most popular model. Do NOT default to the cheapest.
| Task |
Default Model |
model_id |
version_id |
Cost |
Why |
| text_to_image |
SeeDream 4.5 |
doubao-seedream-4.5 |
doubao-seedream-4-5-251128 |
5 pts |
Latest doubao flagship, photorealistic 4K |
| text_to_image (budget) |
Nano Banana2 |
gemini-3.1-flash-image |
gemini-3.1-flash-image |
4 pts |
Fastest and cheapest option |
| text_to_image (premium) |
Nano Banana Pro |
gemini-3-pro-image |
gemini-3-pro-image-preview |
10/10/18 pts |
Premium quality, 1K/2K/4K options |
| text_to_image (artistic) |
Midjourney 🎨 |
midjourney |
v6 |
8/10 pts |
Artist-level aesthetics, creative styles |
| image_to_image |
SeeDream 4.5 |
doubao-seedream-4.5 |
doubao-seedream-4-5-251128 |
5 pts |
Latest, best i2i quality |
| image_to_image (budget) |
Nano Banana2 |
gemini-3.1-flash-image |
gemini-3.1-flash-image |
4 pts |
Cheapest option |
| image_to_image (premium) |
Nano Banana Pro |
gemini-3-pro-image |
gemini-3-pro-image-preview |
10 pts |
Premium quality |
| image_to_image (artistic) |
Midjourney 🎨 |
midjourney |
v6 |
8/10 pts |
Artist-level aesthetics, style transfer |
Selection guide by use case:
- General image generation → SeeDream 4.5 (5pts)
- Custom aspect ratio (16:9, 9:16, 4:3, etc.) → SeeDream 4.5 🌟 or Nano Banana Pro/2/MAX 🆕 (native support)
- Budget-conscious / fast generation → Nano Banana2 (4pts)
- Highest quality with size control (1K/2K/4K) → Nano Banana Pro (text_to_image: 10-18pts, image_to_image: 10pts)
- Artistic/creative styles, illustrations, paintings → Midjourney 🎨 (8-10pts)
- Style transfer / image editing → SeeDream 4.5 (5pts) or Midjourney 🎨 (artistic)
🆕 MAJOR UPDATE: Nano Banana series now has NATIVE aspect_ratio support!
- Nano Banana Pro: ✅ Supports
aspect_ratio (1:1, 16:9, 9:16, 4:3, 3:4) NATIVELY
- Nano Banana2: ✅ Supports
aspect_ratio (1:1, 16:9, 9:16, 4:3, 3:4) NATIVELY
- Nano Banana MAX: ✅ Supports
aspect_ratio (1:1, 16:9, 9:16, 4:3, 3:4) NATIVELY
When user requests unsupported combinations:
Midjourney + aspect_ratio (16:9, etc.): Recommend SeeDream 4.5 or Nano Banana series instead
❌ Midjourney 暂不支持自定义 aspect_ratio(仅支持 1024x1024 方形)
✅ 推荐方案:
1. SeeDream 4.5(支持虚拟参数 aspect_ratio)
2. Nano Banana Pro/2/MAX(原生支持 aspect_ratio)
• 支持比例:1:1, 16:9, 9:16, 4:3, 3:4
• 成本:5 积分(性价比最佳)
• 质量:4K photorealistic
需要我帮你用 SeeDream 4.5 生成吗?
Any model + 8K: Inform user no model supports 8K, max is 4K (Nano Banana Pro or SeeDream 4.5)
Any model + 7:3 ratio: Non-standard ratio, not supported. Suggest closest supported ratio (e.g., 21:9 for ultra-wide, 2:3 for portrait)
Supported Models
⚠️ Production Environment: 4 image models are currently available in production (as of 2026-02-28).
text_to_image (4 models)
| Name |
model_id |
version_id |
Cost |
attribute_id |
Size Options |
| SeeDream 4.5 🌟 |
doubao-seedream-4.5 |
doubao-seedream-4-5-251128 |
5 pts |
2341 |
Default (adaptive 4k) |
| Nano Banana2 💚 |
gemini-3.1-flash-image |
gemini-3.1-flash-image-preview |
4/6/10/13 pts |
4400/4401/4402/4403 |
512px (4pts) / 1K (6pts) / 2K (10pts) / 4K (13pts) |
| Nano Banana Pro |
gemini-3-pro-image |
gemini-3-pro-image-preview |
10/10/18 pts |
2399/2400/2401 |
1K (10pts) / 2K (10pts) / 4K (18pts) |
| Midjourney 🎨 |
midjourney |
v6 |
8/10 pts |
5451/5452 |
480p (8pts) / 720p (10pts) |
image_to_image (4 models)
| Name |
model_id |
version_id |
Cost |
attribute_id |
Size Options |
| SeeDream 4.5 🌟 |
doubao-seedream-4.5 |
doubao-seedream-4-5-251128 |
5 pts |
1611 |
Default (adaptive 4k) |
| Nano Banana2 💚 |
gemini-3.1-flash-image |
gemini-3.1-flash-image-preview |
4/6/10/13 pts |
4404/4405/4406/4407 |
512px (4pts) / 1K (6pts) / 2K (10pts) / 4K (13pts) |
| Nano Banana Pro |
gemini-3-pro-image |
gemini-3-pro-image-preview |
10 pts |
2402/2403/2404 |
1K (10pts) / 2K (10pts) / 4K (18pts) |
| Midjourney 🎨 |
midjourney |
v6 |
8/10 pts |
5453/5454 |
480p (8pts) / 720p (10pts) |
Recommended Defaults (Based on Production Data)
| Task Type |
Default Model |
Reason |
Cost |
| text_to_image |
SeeDream 4.5 |
Latest DouBao flagship, balanced quality/cost |
5 pts |
| text_to_image (budget) |
Nano Banana2 |
Fastest and cheapest option |
4 pts |
| text_to_image (artistic) |
Midjourney 🎨 |
Artist-level aesthetics, creative styles |
8-10 pts |
| image_to_image |
SeeDream 4.5 |
Newest, most stable, cost-effective |
5 pts (attribute_id: 1611) |
| image_to_image (budget) |
Nano Banana2 |
Cheapest option |
4 pts |
| image_to_image (artistic) |
Midjourney 🎨 |
Artist-level aesthetics, style transfer |
8-10 pts |
Premium option: Nano Banana Pro — Highest quality with size control (1K/2K/4K), higher cost (10-18 pts for text_to_image, 10 pts for image_to_image).
Model Capabilities (Parameter Support)
⚠️ Critical: Models have varying parameter support. Custom aspect ratios are now supported by multiple models.
| Model |
Custom Aspect Ratio |
Max Resolution |
Size Options |
Notes |
| SeeDream 4.5 |
✅ (via virtual params) |
4K (adaptive) |
8 aspect ratios |
Supports 1:1, 16:9, 9:16, 4:3, 3:4, 2:3, 3:2, 21:9 (5 pts) |
| Nano Banana2 |
✅ Native support 🆕 |
4K (4096×4096) |
512px/1K/2K/4K + aspect ratios |
Supports 1:1, 16:9, 9:16, 4:3, 3:4; size via attribute_id |
| Nano Banana Pro |
✅ Native support 🆕 |
4K (4096×4096) |
1K/2K/4K + aspect ratios |
Supports 1:1, 16:9, 9:16, 4:3, 3:4; size via attribute_id |
| Midjourney 🎨 |
❌ (1:1 only) |
1024px (square) |
480p/720p via attribute_id |
Fixed 1024x1024, artistic style focus |
Key Capabilities:
- ✅ Aspect ratio control: SeeDream 4.5 (virtual params), Nano Banana Pro/2/MAX (native support)
- ❌ 8K: Not supported by any model (max is 4K)
- ✅ Size control: Nano Banana2, Nano Banana Pro, and Midjourney support multiple size options via different
attribute_ids
- ✅ Budget option: Nano Banana2 is the cheapest at 4 pts for 512px, but 4K costs 13pts
- 🎨 Artistic styles: Midjourney excels at creative, artistic, and illustration styles
- 💡 Best value: SeeDream 4.5 at 5pts offers aspect ratio flexibility; Nano Banana2 512px at 4pts for fastest/cheapest
Environment
Base URL: https://api.imastudio.com
Required/recommended headers for all /open/v1/ endpoints:
| Header |
Required |
Value |
Notes |
Authorization |
✅ |
Bearer ima_your_api_key_here |
API key authentication |
x-app-source |
✅ |
ima_skills |
Fixed value — identifies skill-originated requests |
x_app_language |
recommended |
en / zh |
Product label language; defaults to en if omitted |
Authorization: Bearer ima_your_api_key_here
x-app-source: ima_skills
x_app_language: en
⚠️ MANDATORY: Always Query Product List First
CRITICAL: You MUST call /open/v1/product/list BEFORE creating any task.
The attribute_id field is REQUIRED in the create request. If it is 0 or missing, you get:
"Invalid product attribute" → "Insufficient points" → task fails completely.
NEVER construct a create request from the model table alone. Always fetch the product first.
Why attribute_id is required
The attribute_id uniquely identifies the exact product variant (model + quality tier). The billing and routing system uses it to:
- Validate the product is purchasable
- Deduct the correct credits via
credit_rules
- Route the request to the right backend model
How to get attribute_id
# Step 1: Query product list for the target category
GET /open/v1/product/list?app=ima&platform=web&category=text_to_image
# Step 2: Walk the V2 tree to find your model (type=3 leaf nodes only)
for group in response["data"]:
for version in group.get("children", []):
if version["type"] == "3" and version["model_id"] == target_model_id:
attribute_id = version["credit_rules"][0]["attribute_id"]
credit = version["credit_rules"][0]["points"]
model_version = version["id"] # = version_id
model_name = version["name"]
form_defaults = {f["field"]: f["value"] for f in version["form_config"]}
Quick Reference: Known attribute_ids
⚠️ Production warning: attribute_id and credit values change frequently. Always call /open/v1/product/list at runtime; table below is pre-queried reference (2026-02-27).
text_to_image:
| Model |
model_id |
attribute_id |
credit |
Size |
| SeeDream 4.5 🌟 |
doubao-seedream-4.5 |
2341 |
5 pts |
Default (adaptive 4k) |
| Nano Banana2 (512px) |
gemini-3.1-flash-image |
4400 |
4 pts |
512px (512×512) |
| Nano Banana2 (1K) |
gemini-3.1-flash-image |
4401 |
6 pts |
1K (1024×1024) |
| Nano Banana2 (2K) |
gemini-3.1-flash-image |
4402 |
10 pts |
2K (2048×2048) |
| Nano Banana2 (4K) |
gemini-3.1-flash-image |
4403 |
13 pts |
4K (4096×4096) |
| Nano Banana Pro (1K) |
gemini-3-pro-image |
2399 |
10 pts |
1K (1024×1024) |
| Nano Banana Pro (2K) |
gemini-3-pro-image |
2400 |
10 pts |
2K (2048×2048) |
| Nano Banana Pro (4K) |
gemini-3-pro-image |
2401 |
18 pts |
4K (4096×4096) |
image_to_image:
| Model |
model_id |
attribute_id |
credit |
Size |
| SeeDream 4.5 🌟 |
doubao-seedream-4.5 |
1611 |
5 pts |
Default (adaptive 4k) |
| Nano Banana2 (512px) |
gemini-3.1-flash-image |
4404 |
4 pts |
512px (512×512) |
| Nano Banana2 (1K) |
gemini-3.1-flash-image |
4405 |
6 pts |
1K (1024×1024) |
| Nano Banana2 (2K) |
gemini-3.1-flash-image |
4406 |
10 pts |
2K (2048×2048) |
| Nano Banana2 (4K) |
gemini-3.1-flash-image |
4407 |
13 pts |
4K (4096×4096) |
| Nano Banana Pro (1K) |
gemini-3-pro-image |
2402 |
10 pts |
1K (1024×1024) |
| Nano Banana Pro (2K) |
gemini-3-pro-image |
2403 |
10 pts |
2K (2048×2048) |
| Nano Banana Pro (4K) |
gemini-3-pro-image |
2404 |
10 pts |
4K (4096×4096) |
⚠️ Note: Production has 3 models (SeeDream 4.5 + Nano Banana2 + Nano Banana Pro). All other models mentioned in older documentation are no longer available.
Core Flow
1. GET /open/v1/product/list?app=ima&platform=web&category=<type>
→ REQUIRED: Get attribute_id, credit, model_version, form_config defaults
[image_to_image only]
2. Upload input image → get public HTTPS URL
→ See "Image Upload" section below
3. POST /open/v1/tasks/create
→ Must include: attribute_id, model_name, model_version, credit, cast, prompt (nested!)
4. POST /open/v1/tasks/detail {task_id: "..."}
→ Poll every 2–5s until medias[].resource_status == 1
→ Extract url from completed media
Common Mistakes (and resulting errors)
| Mistake |
Error |
attribute_id is 0 or missing |
"Invalid product attribute" → Insufficient points |
attribute_id outdated (production changed) |
Same errors; always query product list first |
prompt at outer level instead of parameters.parameters.prompt |
Prompt ignored or error |
cast missing from inner parameters |
Billing validation failure |
credit wrong / missing |
Error 6006 |
model_name or model_version missing |
Wrong model routing |
| Skip product list, use hardcoded values |
All of the above |
Image Upload (Required for image_to_image)
The IMA Open API does NOT accept raw bytes or base64 images. All input images must be public HTTPS URLs.
When a user provides an image (local file, bytes, base64), upload it first using the IMA presigned URL flow — the same flow the IMA frontend uses.
Two-Step Upload Flow
Step 1: GET /api/rest/oss/getuploadtoken → { ful, fdl }
Step 2: PUT {ful} with raw image bytes
→ use fdl (CDN URL) as input_images value
See ima-all-ai/SKILL.md → "Image Upload" section for the complete implementation.
Quick Reference
# If user provides a URL already → use directly
if source.startswith("https://"):
input_url = source
# If user provides a local file → upload first
else:
token = get_upload_token(uid, ima_token, suffix="jpeg",
content_type="image/jpeg", ...)
upload_image_to_oss(image_bytes, "image/jpeg", token["ful"])
input_url = token["fdl"] # CDN URL → use as input_images
# Then create task
task_id = create_task("image_to_image", prompt, product,
input_images=[input_url], size="4k")
CDN: https://ima-ga.esxscloud.com/ | OSS: zhubite-imagent-bot.oss-us-east-1.aliyuncs.com
Supported Task Types
| category |
Capability |
Input |
text_to_image |
Text → Image |
prompt |
image_to_image |
Image → Image |
prompt + input image URL |
Detail API status values
| Field |
Type |
Values |
resource_status |
int or null |
0=处理中, 1=可用, 2=失败, 3=已删除;null 当作 0 |
status |
string |
"pending", "processing", "success", "failed" |
resource_status |
status |
Action |
0 or null |
pending / processing |
Keep polling |
1 |
success (or completed) |
Stop when all medias are 1; read url |
1 |
failed |
Stop, handle error |
2 / 3 |
any |
Stop, handle error |
Important: Treat resource_status: null as 0. Stop only when all medias have resource_status == 1. Check status != "failed" when rs=1.
API 1: Product List
GET /open/v1/product/list?app=ima&platform=web&category=text_to_image
Returns a V2 tree structure: type=2 nodes are model groups, type=3 nodes are versions (leaves). Only type=3 nodes
…(truncated)
1---
2name: ima-studio-image-generation
3version: 1.0.2
4category: file-generation
5author: IMA Studio (imastudio.com)
6keywords: imastudio, image generation, text to image, midjourney
7argument-hint: "[text prompt or image URL]"
8description: >
9 Use for AI image generation via IMA Open API. Supports text-to-image and image-to-image.
10 IMPORTANT — Default model selection rule: always recommend the NEWEST and most POPULAR model,
11 NOT the cheapest. Default for text_to_image: SeeDream 4.5 (doubao-seedream-4.5, 5pts) — latest
12 doubao flagship, balanced choice. Budget option: Nano Banana2 (gemini-3.1-flash-image, 4pts) —
13 fastest and cheapest. Premium: Nano Banana Pro (gemini-3-pro-image, 10-18pts) — premium quality
14 with size options (1K/2K/4K). NEW: Midjourney (midjourney, 8-10pts) — artist-level aesthetics.
15 Default for image_to_image: SeeDream 4.5 (doubao-seedream-4.5, 5pts, attribute_id 1611).
16 Production environment has 4 available models. All text_to_image models (4): SeeDream 4.5 (5pts),
17 Nano Banana2 (4pts), Nano Banana Pro (10/10/18pts for 1K/2K/4K), Midjourney (8-10pts for 480p/720p).
18 All image_to_image models (4): SeeDream 4.5 (5pts), Nano Banana2 (4pts), Nano Banana Pro (10pts),
19 Midjourney (8-10pts). Requires an ima_* API key.
20metadata:
21 source: https://skillmd.com/skills/modbender/ima-studio-image-generation
22---
23
24# IMA Image AI Creation
25
26## 💬 User Experience Protocol (IM / Feishu / Discord) v1.3 🆕
27
28> **CRITICAL FIX in v1.2:** Added Step 0 to ensure correct message ordering in group chats.
29> **NEW in v1.3:** Added original image URL in Step 3 caption for easy copying/sharing.
30>
31> **v1.1 Bug:** Confirmation message ("好的!来帮你画...") appeared LAST because it used `NO_REPLY`.
32> **v1.2 Fix:** Always reply with confirmation FIRST (Step 0), then push updates via `message` tool.
33> **v1.3 Enhancement:** Include `🔗 原始链接:[url]` in success caption so users can copy/share the URL.
34
35This skill runs inside IM platforms (Feishu, Discord via OpenClaw).
36**Never let users wait in silence.** Always follow all 6 steps below, every single time.
37
38### 🚫 Never Say to Users
39
40| ❌ Never say | ✅ What users care about |
41|-------------|--------------------------|
42| `ima_image_create.py` / 脚本 / script | — |
43| 自动化脚本 / automation | — |
44| 自动处理产品列表 / 查询接口 | — |
45| 自动解析参数 / 智能轮询 | — |
46| attribute_id / model_version / form_config | — |
47| API 调用 / HTTP 请求 / 任何技术参数名 | — |
48
49Only tell users: **model name · estimated time · credits · result (image/media) · plain-language status**.
50
51---
52
53### Estimated Generation Time per Model
54
55| Model | Estimated Time | Poll Every | Send Progress Every |
56|-------|---------------|------------|---------------------|
57| **SeeDream 4.5** 🌟 | 30~60s | 5s | 20s |
58| **Nano Banana2** 💚 | 20~40s | 5s | 15s |
59| **Nano Banana Pro** | 60~120s | 5s | 30s |
60| **Midjourney** 🎨 | 40~90s | 8s | 25s |
61
62`estimated_max_seconds` = the upper bound of the range above (e.g. 60 for SeeDream 4.5, 120 for Nano Banana Pro, 90 for Midjourney).
63
64---
65
66### Step 0 — Initial Acknowledgment Reply (Normal Reply) 🆕
67
68**⚠️ CRITICAL:** This step is NEW in v1.2 and fixes the message ordering bug.
69
70**Before doing anything else**, reply to the user with a friendly acknowledgment message using your **normal reply** (not `message` tool). This reply will automatically appear FIRST in the conversation.
71
72**Example acknowledgment messages:**
73```
74好的!来帮你画一只萌萌的猫咪 🐱
75```
76```
77收到!马上为你生成一张 16:9 的风景照 🏔️
78```
79```
80OK! Starting image generation with SeeDream 4.5 🎨
81```
82
83**Rules:**
84- Keep it short and warm (< 15 words)
85- Match the user's language (Chinese/English)
86- Include relevant emoji (🐱/🎨/✨)
87- This is your ONLY normal reply — all subsequent updates use `message` tool
88
89**Why this matters:**
90- Normal replies automatically appear FIRST in the conversation thread
91- `message` tool pushes appear in chronological order AFTER your initial reply
92- This ensures users see: "好的!" → "🎨 开始生成..." → "✅ 成功!" (correct order)
93
94---
95
96### Step 1 — Pre-Generation Notification (Push via message tool)
97
98**After Step 0 reply**, use the `message` tool to push a notification immediately to the group/channel:
99
100```python
101# Agent implementation
102message(
103 action="send",
104 target=group_id, # or channel_id for Discord
105 message="""🎨 开始生成图片,请稍候…
106• 模型:[Model Name]
107• 预计耗时:[X ~ Y 秒]
108• 消耗积分:[N pts]"""
109)
110```
111
112**User-facing message template:**
113```
114🎨 开始生成图片,请稍候…
115• 模型:[Model Name]
116• 预计耗时:[X ~ Y 秒]
117• 消耗积分:[N pts]
118```
119
120**Cost transparency examples:**
121- Balanced/default (5-6 pts): "使用 SeeDream 4.5(5 积分,性价比最佳)"
122- Premium (>10 pts): "使用 Nano Banana Pro(10-18 积分,最高质量,支持 1K/2K/4K)"
123- Budget (user explicit): "使用 Nano Banana2(4 积分,最便宜最快)"
124
125> Adapt language to match the user. Chinese → `🎨 开始生成图片,请稍候…` / English → `🎨 Starting image generation, please wait…`
126
127---
128
129### Step 2 — Progress Updates (Push via message tool)
130
131**Implementation:**
132
1331. Start the generation script in background or use polling loop
1342. Track elapsed time since start
1353. Every `[Send Progress Every]` seconds (from table above), push a progress update via `message` tool
1364. Stop when task completes (success/failure)
137
138**Progress message template:**
139```
140⏳ 正在生成中… [P]%
141已等待 [elapsed]s,预计最长 [max]s
142```
143
144**Progress formula:**
145```python
146P = min(95, floor(elapsed_seconds / estimated_max_seconds * 100))
147```
148
149**Rules:**
150- **Cap at 95%** — never show 100% until the API returns `success`
151- If `elapsed > estimated_max`: keep P at 95% and append `「稍等,即将完成…」`
152- Example: elapsed=40s, max=60s → P = min(95, floor(40/60*100)) = min(95, 66) = **66%**
153
154**When to send progress:**
155- **Short tasks (<20s)**: No progress needed, skip Step 2
156- **Medium tasks (20-60s)**: Send 1-2 updates
157- **Long tasks (>60s)**: Send updates every 20-30s
158
159---
160
161### Step 3 — Success Notification (Push image via message tool)
162
163When task status = `success`, use the `message` tool to **send the generated image directly** (not as a text URL):
164
165**Agent implementation:**
166```python
167# Get result URL from script output or task detail API
168result = get_task_result(task_id)
169image_url = result["medias"][0]["url"]
170
171# Push image + caption to group/channel
172message(
173 action="send",
174 target=group_id,
175 media=image_url, # Feishu/Discord will render the image
176 caption="""✅ 图片生成成功!
177• 模型:[Model Name]
178• 耗时:预计 [X~Y]s,实际 [actual]s
179• 消耗积分:[N pts]
180
181🔗 原始链接:[image_url]"""
182)
183```
184
185**User-facing message:**
186```
187✅ 图片生成成功!
188• 模型:[Model Name]
189• 耗时:预计 [X~Y]s,实际 [actual]s
190• 消耗积分:[N pts]
191
192🔗 原始链接:https://...
193
194[图片直接显示在上方]
195```
196
197**Platform-specific notes:**
198- **Feishu**: `message(action=send, media=url, caption="...")` — caption appears below image
199- **Discord**: Image embeds automatically from URL; caption can be in message text
200- **Telegram**: Use `message(action=send, media=url, caption="...")`
201
202**⚠️ Important**: Do NOT send plain text URL like `https://cdn.../image.jpg`. Users expect to see the actual image rendered.
203
204---
205
206### Step 4 — Failure Notification (Push via message tool)
207
208When task status = `failed` or any API/network error, push a failure message with alternative suggestions:
209
210**Agent implementation:**
211```python
212message(
213 action="send",
214 target=group_id,
215 message="""❌ 图片生成失败
216• 原因:[natural_language_error_message]
217• 建议改用:
218 - [Alt Model 1]([特点],[N pts])
219 - [Alt Model 2]([特点],[N pts])
220
221需要我帮你用其他模型重试吗?"""
222)
223```
224
225**⚠️ CRITICAL: Error Message Translation**
226
227**NEVER show technical error messages to users.** Always translate API errors into natural language:
228
229| Technical Error | ❌ Never Say | ✅ Say Instead (Chinese) | ✅ Say Instead (English) |
230|----------------|-------------|------------------------|------------------------|
231| `"Invalid product attribute"` / `"Insufficient points"` | Invalid product attribute | 生成参数配置异常,请稍后重试 | Configuration error, please try again later |
232| `Error 6006` (credit mismatch) | Error 6006 | 积分计算异常,系统正在修复 | Points calculation error, system is fixing |
233| `Error 6010` (attribute_id mismatch) | Attribute ID does not match | 模型参数不匹配,请尝试其他模型 | Model parameters incompatible, try another model |
234| `error 400` (bad request, e.g. invalid size) | error 400 / Bad request | 图片参数设置有误,请调整尺寸或比例 | Image parameter error, adjust size or aspect ratio |
235| `resource_status == 2` | Resource status 2 / Failed | 图片生成遇到问题,建议换个模型试试 | Image generation failed, try another model |
236| `status == "failed"` (no details) | Task failed | 这次生成没成功,要不换个模型试试? | Generation unsuccessful, try a different model? |
237| `timeout` | Task timed out / Timeout error | 生成时间过长已超时,建议用更快的模型 | Generation took too long, try a faster model |
238| Network error / Connection refused | Connection refused / Network error | 网络连接不稳定,请检查网络后重试 | Network connection unstable, check network and retry |
239| API key invalid | Invalid API key / 401 Unauthorized | API 密钥无效,请联系管理员 | API key invalid, contact administrator |
240| Rate limit exceeded | 429 Too Many Requests / Rate limit | 请求过于频繁,请稍等片刻再试 | Too many requests, please wait a moment |
241| Model unavailable | Model not available / 503 Service Unavailable | 当前模型暂时不可用,建议换个模型 | Model temporarily unavailable, try another model |
242| Unsupported aspect ratio (Nano Banana Pro) | Parameter not supported | 该模型不支持自定义比例,推荐使用 SeeDream 4.5 | This model doesn't support custom aspect ratios, try SeeDream 4.5 |
243
244**Generic fallback (when error is unknown):**
245- Chinese: `图片生成遇到问题,请稍后重试或换个模型试试`
246- English: `Image generation encountered an issue, please try again or use another model`
247
248**Best Practices:**
2491. **Focus on user action**: Tell users what to do next, not what went wrong technically
2502. **Be reassuring**: Use phrases like "建议换个模型试试" instead of "生成失败了"
2513. **Avoid blame**: Never say "你的参数有问题" → say "参数需要调整一下"
2524. **Provide alternatives**: Always suggest 1-2 alternative models in the failure message
2535. **Image-specific**: For aspect ratio errors, recommend SeeDream 4.5 (supports custom ratios)
254
255**Failure fallback table:**
256
257| Failed Model | First Alt | Second Alt |
258|-------------|-----------|------------|
259| **SeeDream 4.5** | **Nano Banana2**(4pts,快速便宜) | **Nano Banana Pro**(10-18pts,高质量) |
260| **Nano Banana2** | **SeeDream 4.5**(5pts,更高质量) | **Nano Banana Pro**(10-18pts) |
261| **Nano Banana Pro** | **SeeDream 4.5**(5pts,性价比高) | **Nano Banana2**(4pts,最便宜) |
262| Any / Unknown | **SeeDream 4.5**(5pts,默认首选) | **Nano Banana2**(4pts,预算紧张) |
263
264---
265
266### Step 5 — Done (No Further Action Needed) 🆕
267
268**v1.2 Change:** Step 5 is now simplified.
269
270After completing Steps 0-4:
271- ✅ **Step 0** already sent your normal reply (appears FIRST in chat)
272- ✅ **Steps 1-4** pushed all updates via `message` tool (appear in order)
273- ✅ **No further action needed** — conversation is complete
274
275**Do NOT:**
276- ❌ Reply again with `NO_REPLY` (you already replied in Step 0)
277- ❌ Send duplicate confirmation messages
278- ❌ Use `message` tool to send the same content twice
279
280**Why this works:**
281```
282User: "帮我画一只猫"
283 ↓
284[Step 0] Your normal reply: "好的!来帮你画一只萌萌的猫咪 🐱" ← Appears FIRST
285 ↓
286[Step 1] message tool push: "🎨 开始生成图片..." ← Appears SECOND
287 ↓
288[Step 2] message tool push: "⏳ 正在生成中… 45%" ← (if task takes >20s)
289 ↓
290[Step 3] message tool push: "✅ 图片生成成功! [图片]" ← Appears LAST
291 ↓
292[Step 5] Done. No further replies.
293```
294
295---
296
297### 🎯 Summary: What Changed in v1.2 & v1.3
298
299| Version | Step | Change |
300|---------|------|--------|
301| **v1.2** | Step 0 | ✅ **NEW:** Normal reply with acknowledgment (appears FIRST) |
302| **v1.2** | Step 1 | Use `message` tool for **notification only** (not all messages) |
303| **v1.2** | Step 5 | ✅ **FIXED:** No further action (already replied in Step 0), no `NO_REPLY` |
304| **v1.3** | Step 3 | ✅ **NEW:** Added `🔗 原始链接:[url]` in caption for easy copying |
305
306**Root cause of v1.1 bug:**
307- v1.1 used `message` tool for ALL messages (including acknowledgment)
308- Then replied `NO_REPLY` to suppress normal reply
309- Result: Acknowledgment appeared LAST (because `message` tool pushes are chronological)
310
311**v1.2 fix:**
312- Step 0 uses normal reply (automatically appears FIRST)
313- Steps 1-4 use `message` tool (appear in chronological order)
314- No `NO_REPLY` needed (already replied in Step 0)
315
316**v1.3 enhancement:**
317- Step 3 caption now includes original image URL
318- Users can easily copy/share the link without asking
319
320---
321
322## Complete Example: Correct v1.2 Flow
323
324```python
325# User: "帮我画一只可爱的猫咪"
326
327# Step 0: Normal reply (appears FIRST in chat)
328# Agent's normal response mechanism automatically handles this
329reply_text = "好的!来帮你画一只萌萌的猫咪 🐱"
330# (This is your normal LLM response, not a tool call)
331
332# Step 1: Push start notification
333message(
334 action="send",
335 target="oc_b30b266d43b69674e3ad160de9d13cf2",
336 message="🎨 开始生成图片,请稍候…\n• 模型:SeeDream 4.5\n• 预计耗时:30~60秒\n• 消耗积分:5 pts"
337)
338
339# Background: Start generation
340exec(command="python3 ima_image_create.py ...", background=True, sessionId=sid)
341
342# Step 2: Progress updates (if task takes >20s)
343# (Poll in background and push updates via message tool)
344start_time = time.time()
345while not done:
346 elapsed = int(time.time() - start_time)
347 if elapsed >= 20 and elapsed % 20 == 0: # Every 20s
348 progress = min(95, int(elapsed / 60 * 100))
349 message(
350 action="send",
351 target="oc_b30b266d43b69674e3ad160de9d13cf2",
352 message=f"⏳ 正在生成中… {progress}%\n已等待 {elapsed}s,预计最长 60s"
353 )
354 time.sleep(5) # Poll every 5s
355
356# Step 3: Success (push image)
357result = get_result(task_id)
358message(
359 action="send",
360 target="oc_b30b266d43b69674e3ad160de9d13cf2",
361 media="https://ws.esxscloud.com/.../image.jpeg",
362 caption=f"✅ 图片生成成功!\n• 模型:SeeDream 4.5\n• 耗时:实际 35s\n• 消耗积分:5 pts\n\n🔗 原始链接:{result['url']}"
363)
364
365# Step 5: Done — no further action
366# (Do NOT reply again, do NOT use NO_REPLY)
367```
368
369**Result in chat (correct order):**
370```
371[User] 帮我画一只可爱的猫咪
372
373[Agent] 好的!来帮你画一只萌萌的猫咪 🐱 ← Step 0 (normal reply)
374
375[Agent] 🎨 开始生成图片,请稍候… ← Step 1 (message tool)
376 • 模型:SeeDream 4.5
377 • 预计耗时:30~60秒
378 • 消耗积分:5 pts
379
380[Agent] ⏳ 正在生成中… 66% ← Step 2 (message tool, if >20s)
381 已等待 40s,预计最长 60s
382
383[Agent] ✅ 图片生成成功! ← Step 3 (message tool)
384 • 模型:SeeDream 4.5
385 • 耗时:实际 35s
386 • 消耗积分:5 pts
387
388 🔗 原始链接:https://...
389 [图片]
390```
391
392---
393
394## ⚙️ How This Skill Works
395
396**For transparency:** This skill uses a bundled Python script (`scripts/ima_image_create.py`) to call the IMA Open API. The script:
397- Sends your prompt to IMA's servers (two domains, see below)
398- Uses `--user-id` **only locally** as a key for storing your model preferences
399- Returns an image URL when generation is complete
400
401### 🌐 Network Endpoints Used
402
403This skill connects to **two domains** owned by IMA Studio for complete functionality:
404
405| Domain | Purpose | What's Sent | Authentication |
406|--------|---------|-------------|----------------|
407| `api.imastudio.com` | Main API (task creation, status polling) | Prompts, model params, task IDs | Bearer token (IMA API key) |
408| `imapi.liveme.com` | Image upload service (OSS token generation) | Image files (for i2i tasks), IMA API key | IMA API key + APP_KEY signature |
409
410**Why two domains?**
411- `api.imastudio.com`: IMA's image generation API (handles task orchestration)
412- `imapi.liveme.com`: IMA's media storage infrastructure (handles large file uploads)
413- Both services are **owned and operated by IMA Studio**
414
415**Privacy implications:**
416- Your IMA API key is sent to **both domains** for authentication
417- Image files are uploaded to `imapi.liveme.com` to obtain CDN URLs (for image_to_image tasks)
418- Image generation happens on `api.imastudio.com` using the CDN URLs
419- For text_to_image tasks (no image input), only `api.imastudio.com` is contacted
420
421**Security verification:**
422```bash
423# List all network endpoints in the code:
424grep -n "https://" scripts/ima_image_create.py
425
426# Expected output:
427# 60: DEFAULT_BASE_URL = "https://api.imastudio.com"
428# 61: DEFAULT_IM_BASE_URL = "https://imapi.liveme.com"
429```
430
431**If you're concerned about the two-domain architecture:**
4321. Review IMA Studio's privacy policy at https://imastudio.com/privacy
4332. Contact IMA technical support to confirm domain ownership: support@imastudio.com
4343. Use a test/scoped API key first (see security notice below)
4354. Monitor network traffic during first run (instructions in SECURITY.md)
436
437### ⚠️ Credential Security Notice
438
439**Your IMA API key is sent to TWO domains:**
4401. `api.imastudio.com` — Main image generation API
4412. `imapi.liveme.com` — Image upload service (only when using image_to_image tasks)
442
443**Both domains are owned by IMA Studio**, but if you're concerned about credential exposure:
444
445✅ **Best practices:**
446- Use a **test/scoped API key** for initial testing (create at https://imastudio.com/api-keys)
447- Set a low quota (e.g., 100 credits) for the test key
448- Rotate your key after testing if needed
449- Monitor network traffic during first run (see SECURITY.md § "Network Traffic Verification")
450- Contact IMA support to confirm domain ownership: support@imastudio.com
451
452❌ **Do NOT:**
453- Use a production key if you're uncomfortable with the two-domain architecture
454- Share your API key with others
455- Commit your API key to version control
456
457**What gets sent to IMA servers:**
458- ✅ Your image prompt/description
459- ✅ Model selection (SeeDream/Nano Banana/Midjourney)
460- ✅ Image parameters (size, quality, aspect ratio, etc.)
461- ✅ Image files (for image_to_image tasks, uploaded to `imapi.liveme.com`)
462- ✅ IMA API key (for authentication to both domains)
463- ❌ NO user_id (it's only used locally)
464
465**What's stored locally:**
466- `~/.openclaw/memory/ima_prefs.json` - Your model preferences (< 1 KB)
467- `~/.openclaw/logs/ima_skills/` - Generation logs (auto-deleted after 7 days)
468- See [SECURITY.md](SECURITY.md) for complete privacy policy
469
470### Agent Execution (Internal Reference)
471
472> **Note for users:** You can review the script source at `scripts/ima_image_create.py` anytime.
473> The agent uses this script to simplify API calls. Network requests go to two IMA Studio domains: `api.imastudio.com` (API) and `imapi.liveme.com` (image uploads for i2i tasks).
474
475Use the bundled script internally to ensure correct parameter construction:
476
477```bash
478# List available models
479python3 {baseDir}/scripts/ima_image_create.py \
480 --api-key $IMA_API_KEY \
481 --task-type text_to_image \
482 --list-models
483
484# Generate image
485python3 {baseDir}/scripts/ima_image_create.py \
486 --api-key $IMA_API_KEY \
487 --task-type text_to_image \
488 --model-id doubao-seedream-4.5 \
489 --prompt "a cute puppy running on grass" \
490 --user-id {user_id} \
491 --output-json
492
493# Image to image
494python3 {baseDir}/scripts/ima_image_create.py \
495 --api-key $IMA_API_KEY \
496 --task-type image_to_image \
497 --model-id doubao-seedream-4.5 \
498 --prompt "turn into oil painting style" \
499 --input-images https://example.com/photo.jpg \
500 --user-id {user_id} \
501 --output-json
502```
503
504The script outputs JSON — parse it to get the result URL and pass it to the user via the UX protocol messages above.
505
506---
507
508## Overview
509
510Call IMA Open API to create AI-generated images. All endpoints require an `ima_*` API key. The core flow is: **query products → create task → poll until done**.
511
512---
513
514## 🔒 Security & Transparency Policy
515
516> **This skill is community-maintained and open for inspection.**
517
518### ✅ What Users CAN Do
519
520**Full transparency:**
521- ✅ **Review all source code**: Check `scripts/ima_image_create.py` and `ima_logger.py` anytime
522- ✅ **Verify network calls**: Network requests go to two IMA Studio domains: `api.imastudio.com` (API) and `imapi.liveme.com` (image uploads for i2i tasks). See "🌐 Network Endpoints Used" section above for full details.
523- ✅ **Inspect local data**: View `~/.openclaw/memory/ima_prefs.json` and log files
524- ✅ **Control privacy**: Delete preferences/logs anytime, or disable file writes (see below)
525
526**Configuration allowed:**
527- ✅ **Set API key** in environment or agent config:
528 - Environment variable: `export IMA_API_KEY=ima_your_key_here`
529 - OpenClaw/MCP config: Add `IMA_API_KEY` to agent's environment configuration
530 - Get your key at: https://imastudio.com
531- ✅ **Use scoped/test keys**: Test with limited API keys, rotate after testing
532- ✅ **Disable file writes**: Make prefs/logs read-only or symlink to `/dev/null`
533
534**Data control:**
535- ✅ **View stored data**: `cat ~/.openclaw/memory/ima_prefs.json`
536- ✅ **Delete preferences**: `rm ~/.openclaw/memory/ima_prefs.json` (resets to defaults)
537- ✅ **Delete logs**: `rm -rf ~/.openclaw/logs/ima_skills/` (auto-cleanup after 7 days anyway)
538- ✅ **Review security**: See [SECURITY.md](SECURITY.md) for complete privacy policy
539
540### ⚠️ Advanced Users: Fork & Modify
541
542If you need to modify this skill for your use case:
5431. **Fork the repository** (don't modify the original)
5442. **Update your fork** with your changes
5453. **Test thoroughly** with limited API keys
5464. **Document your changes** for troubleshooting
547
548**Note:** Modified skills may break API compatibility or introduce security issues. Official support only covers the unmodified version.
549
550### ❌ What to AVOID (Security Risks)
551
552**Actions that could compromise security:**
553- ❌ Sharing API keys publicly or in skill files
554- ❌ Modifying API endpoints to unknown servers
555- ❌ Disabling SSL/TLS certificate verification
556- ❌ Logging sensitive user data (prompts, IDs, etc.)
557- ❌ Bypassing authentication or billing mechanisms
558
559**Why this matters:**
5601. **API Compatibility**: Skill logic aligns with IMA Open API schema
5612. **Security**: Malicious modifications could leak credentials or bypass billing
5623. **Support**: Modified skills may not be supported
5634. **Community**: Breaking changes affect all users
564
565### 📋 Privacy & Data Handling Summary
566
567**What this skill does with your data:**
568
569| Data Type | Sent to IMA? | Stored Locally? | User Control |
570|-----------|-------------|-----------------|--------------|
571| Image prompts | ✅ Yes (required for generation) | ❌ No | None (required) |
572| API key | ✅ Yes (authentication header) | ❌ No | Set via env var |
573| user_id (optional CLI arg) | ❌ **Never** (local preference key only) | ✅ Yes (as prefs file key) | Change `--user-id` value |
574| Model preferences | ❌ No | ✅ Yes (~/.openclaw) | Delete anytime |
575| Generation logs | ❌ No | ✅ Yes (~/.openclaw) | Auto-cleanup 7 days |
576
577**Privacy recommendations:**
5781. **Use test/scoped API keys** for initial testing
5792. **Note**: `--user-id` is **never sent to IMA servers** - it's only used locally as a key for storing preferences in `~/.openclaw/memory/ima_prefs.json`
5803. **Review source code** at `scripts/ima_image_create.py` to verify network calls (search for `create_task` function)
5814. **Rotate API keys** after testing or if compromised
582
583**Get your IMA API key:** Visit https://imastudio.com to register and get started.
584
585### 🔧 For Skill Maintainers Only
586
587**Version control:**
588- All changes must go through Git with proper version bumps (semver)
589- CHANGELOG.md must document all changes
590- Production deployments require code review
591
592**File checksums (optional):**
593```bash
594# Verify skill integrity
595sha256sum SKILL.md scripts/ima_image_create.py
596```
597
598If users report issues, verify file integrity first.
599
600---
601
602## 🧠 User Preference Memory
603
604> User preferences **override** recommended defaults. If a user has generated before, use their preferred model — not the system default.
605
606### Storage
607
608Preferences are stored in `~/.openclaw/memory/ima_prefs.json`:
609
610```json
611{
612 "user_{user_id}": {
613 "text_to_image": {
614 "model_id": "doubao-seedream-4.5",
615 "model_name": "SeeDream 4.5",
616 "credit": 5,
617 "last_used": "2026-02-26T03:07:27Z"
618 },
619 "image_to_image": {
620 "model_id": "doubao-seedream-4.5",
621 "model_name": "SeeDream 4.5",
622 "credit": 5,
623 "last_used": "2026-02-25T10:00:00Z"
624 }
625 }
626}
627```
628
629If the file or key doesn't exist, fall back to the ⭐ Recommended Defaults below.
630
631---
632
633### When to Read (Before Every Generation)
634
6351. Load `~/.openclaw/memory/ima_prefs.json` (silently, no error if missing)
6362. Look up `user_{user_id}.{task_type}` (e.g. `user_12345.text_to_image`)
6373. **If found** → use that model; mention it in the pre-generation notification:
638 ```
639 🎨 根据你的使用习惯,将用 [Model Name] 帮你生成图片…
640 • 模型:[Model Name](你的常用模型)
641 • 预计耗时:[X ~ Y 秒]
642 • 消耗积分:[N pts]
643 ```
6444. **If not found** → use the ⭐ Recommended Default and skip any mention of "习惯"
645
646---
647
648### When to Write (After Every Successful Generation)
649
650After task status = `success`, save the used model back to the preference file:
651
652```python
653import json, os
654from datetime import datetime, timezone
655
656prefs_path = os.path.expanduser("~/.openclaw/memory/ima_prefs.json")
657os.makedirs(os.path.dirname(prefs_path), exist_ok=True)
658
659try:
660 with open(prefs_path) as f:
661 prefs = json.load(f)
662except (FileNotFoundError, json.JSONDecodeError):
663 prefs = {}
664
665user_key = f"user_{user_id}"
666prefs.setdefault(user_key, {})[task_type] = {
667 "model_id": model_id,
668 "model_name": model_name,
669 "credit": credit,
670 "last_used": datetime.now(timezone.utc).isoformat(),
671}
672
673with open(prefs_path, "w") as f:
674 json.dump(prefs, f, ensure_ascii=False, indent=2)
675```
676
677---
678
679### When to Update (User Explicitly Changes Model)
680
681Detect intent in user messages. Trigger phrases (Chinese + English):
682
683| Trigger | Action |
684|---------|--------|
685| `用XXX` / `换成XXX` / `改用XXX` | Switch to named model for this request AND save as new preference |
686| `以后都用XXX` / `默认用XXX` / `always use XXX` | Save as preference, confirm: `✅ 已记住!以后图片生成默认用 [XXX]` |
687| `换个模型` / `try another model` | Ask user to choose; save chosen model as new preference |
688| `用最好的` / `best quality` / `最强的` | Use highest-quality model (Nano Banana Pro); save preference |
689| `用便宜的` / `cheapest` | Use lowest-cost model; do NOT save as preference unless user says "以后都用" |
690
691---
692
693### Preference Confirmation Message
694
695When switching to a different model than their preference, confirm:
696
697```
698💡 你之前喜欢用 [Old Model]。这次你选了 [New Model],要把它设为默认吗?
699回复「是」保存 / 回复「否」仅本次使用
700```
701
702---
703
704## ⭐ Recommended Defaults
705
706> **These are fallback defaults — only used when no user preference exists.**
707> **Always default to the newest and most popular model. Do NOT default to the cheapest.**
708
709| Task | Default Model | model_id | version_id | Cost | Why |
710|------|--------------|----------|------------|------|-----|
711| text_to_image | **SeeDream 4.5** | `doubao-seedream-4.5` | `doubao-seedream-4-5-251128` | 5 pts | Latest doubao flagship, photorealistic 4K |
712| text_to_image (budget) | **Nano Banana2** | `gemini-3.1-flash-image` | `gemini-3.1-flash-image` | 4 pts | Fastest and cheapest option |
713| text_to_image (premium) | **Nano Banana Pro** | `gemini-3-pro-image` | `gemini-3-pro-image-preview` | 10/10/18 pts | Premium quality, 1K/2K/4K options |
714| text_to_image (artistic) | **Midjourney** 🎨 | `midjourney` | `v6` | 8/10 pts | Artist-level aesthetics, creative styles |
715| image_to_image | **SeeDream 4.5** | `doubao-seedream-4.5` | `doubao-seedream-4-5-251128` | 5 pts | Latest, best i2i quality |
716| image_to_image (budget) | **Nano Banana2** | `gemini-3.1-flash-image` | `gemini-3.1-flash-image` | 4 pts | Cheapest option |
717| image_to_image (premium) | **Nano Banana Pro** | `gemini-3-pro-image` | `gemini-3-pro-image-preview` | 10 pts | Premium quality |
718| image_to_image (artistic) | **Midjourney** 🎨 | `midjourney` | `v6` | 8/10 pts | Artist-level aesthetics, style transfer |
719
720**Selection guide by use case:**
721- General image generation → **SeeDream 4.5** (5pts)
722- **Custom aspect ratio (16:9, 9:16, 4:3, etc.)** → **SeeDream 4.5** 🌟 or **Nano Banana Pro/2/MAX** 🆕 (native support)
723- Budget-conscious / fast generation → **Nano Banana2** (4pts)
724- Highest quality with size control (1K/2K/4K) → **Nano Banana Pro** (text_to_image: 10-18pts, image_to_image: 10pts)
725- **Artistic/creative styles, illustrations, paintings** → **Midjourney** 🎨 (8-10pts)
726- Style transfer / image editing → **SeeDream 4.5** (5pts) or **Midjourney** 🎨 (artistic)
727
728**🆕 MAJOR UPDATE: Nano Banana series now has NATIVE aspect_ratio support!**
729- **Nano Banana Pro**: ✅ Supports `aspect_ratio` (1:1, 16:9, 9:16, 4:3, 3:4) NATIVELY
730- **Nano Banana2**: ✅ Supports `aspect_ratio` (1:1, 16:9, 9:16, 4:3, 3:4) NATIVELY
731- **Nano Banana MAX**: ✅ Supports `aspect_ratio` (1:1, 16:9, 9:16, 4:3, 3:4) NATIVELY
732
733**When user requests unsupported combinations:**
734- **Midjourney + aspect_ratio (16:9, etc.)**: Recommend **SeeDream 4.5** or **Nano Banana series** instead
735 ```
736 ❌ Midjourney 暂不支持自定义 aspect_ratio(仅支持 1024x1024 方形)
737
738 ✅ 推荐方案:
739 1. SeeDream 4.5(支持虚拟参数 aspect_ratio)
740 2. Nano Banana Pro/2/MAX(原生支持 aspect_ratio)
741 • 支持比例:1:1, 16:9, 9:16, 4:3, 3:4
742 ```
743 • 成本:5 积分(性价比最佳)
744 • 质量:4K photorealistic
745
746 需要我帮你用 SeeDream 4.5 生成吗?
747 ```
748- **Any model + 8K**: Inform user no model supports 8K, max is 4K (Nano Banana Pro or SeeDream 4.5)
749- **Any model + 7:3 ratio**: Non-standard ratio, not supported. Suggest closest supported ratio (e.g., 21:9 for ultra-wide, 2:3 for portrait)
750
751---
752
753## Supported Models
754
755⚠️ **Production Environment**: **4 image models** are currently available in production (as of 2026-02-28).
756
757### text_to_image (4 models)
758
759| Name | model_id | version_id | Cost | attribute_id | Size Options |
760|------|----------|------------|------|--------------|--------------|
761| **SeeDream 4.5** 🌟 | `doubao-seedream-4.5` | `doubao-seedream-4-5-251128` | 5 pts | 2341 | Default (adaptive 4k) |
762| **Nano Banana2** 💚 | `gemini-3.1-flash-image` | `gemini-3.1-flash-image-preview` | 4/6/10/13 pts | 4400/4401/4402/4403 | 512px (4pts) / 1K (6pts) / 2K (10pts) / 4K (13pts) |
763| **Nano Banana Pro** | `gemini-3-pro-image` | `gemini-3-pro-image-preview` | 10/10/18 pts | 2399/2400/2401 | 1K (10pts) / 2K (10pts) / 4K (18pts) |
764| **Midjourney** 🎨 | `midjourney` | `v6` | 8/10 pts | 5451/5452 | 480p (8pts) / 720p (10pts) |
765
766### image_to_image (4 models)
767
768| Name | model_id | version_id | Cost | attribute_id | Size Options |
769|------|----------|------------|------|--------------|--------------|
770| **SeeDream 4.5** 🌟 | `doubao-seedream-4.5` | `doubao-seedream-4-5-251128` | 5 pts | 1611 | Default (adaptive 4k) |
771| **Nano Banana2** 💚 | `gemini-3.1-flash-image` | `gemini-3.1-flash-image-preview` | 4/6/10/13 pts | 4404/4405/4406/4407 | 512px (4pts) / 1K (6pts) / 2K (10pts) / 4K (13pts) |
772| **Nano Banana Pro** | `gemini-3-pro-image` | `gemini-3-pro-image-preview` | 10 pts | 2402/2403/2404 | 1K (10pts) / 2K (10pts) / 4K (18pts) |
773| **Midjourney** 🎨 | `midjourney` | `v6` | 8/10 pts | 5453/5454 | 480p (8pts) / 720p (10pts) |
774
775### Recommended Defaults (Based on Production Data)
776
777| Task Type | Default Model | Reason | Cost |
778|-----------|---------------|--------|------|
779| **text_to_image** | SeeDream 4.5 | Latest DouBao flagship, balanced quality/cost | 5 pts |
780| **text_to_image (budget)** | Nano Banana2 | Fastest and cheapest option | 4 pts |
781| **text_to_image (artistic)** | Midjourney 🎨 | Artist-level aesthetics, creative styles | 8-10 pts |
782| **image_to_image** | SeeDream 4.5 | Newest, most stable, cost-effective | 5 pts (attribute_id: 1611) |
783| **image_to_image (budget)** | Nano Banana2 | Cheapest option | 4 pts |
784| **image_to_image (artistic)** | Midjourney 🎨 | Artist-level aesthetics, style transfer | 8-10 pts |
785
786**Premium option**: Nano Banana Pro — Highest quality with size control (1K/2K/4K), higher cost (10-18 pts for text_to_image, 10 pts for image_to_image).
787
788### Model Capabilities (Parameter Support)
789
790⚠️ **Critical**: Models have **varying parameter support**. Custom aspect ratios are now **supported by multiple models**.
791
792| Model | Custom Aspect Ratio | Max Resolution | Size Options | Notes |
793|-------|---------------------|----------------|--------------|-------|
794| **SeeDream 4.5** | ✅ (via virtual params) | 4K (adaptive) | 8 aspect ratios | Supports 1:1, 16:9, 9:16, 4:3, 3:4, 2:3, 3:2, 21:9 (5 pts) |
795| **Nano Banana2** | ✅ **Native support** 🆕 | 4K (4096×4096) | 512px/1K/2K/4K + aspect ratios | Supports 1:1, 16:9, 9:16, 4:3, 3:4; size via `attribute_id` |
796| **Nano Banana Pro** | ✅ **Native support** 🆕 | 4K (4096×4096) | 1K/2K/4K + aspect ratios | Supports 1:1, 16:9, 9:16, 4:3, 3:4; size via `attribute_id` |
797| **Midjourney** 🎨 | ❌ (1:1 only) | 1024px (square) | 480p/720p via `attribute_id` | Fixed 1024x1024, artistic style focus |
798
799**Key Capabilities**:
800- ✅ **Aspect ratio control**: **SeeDream 4.5** (virtual params), **Nano Banana Pro/2/MAX** (native support)
801- ❌ **8K**: Not supported by any model (max is 4K)
802- ✅ **Size control**: **Nano Banana2**, **Nano Banana Pro**, and **Midjourney** support multiple size options via different `attribute_id`s
803- ✅ **Budget option**: **Nano Banana2** is the cheapest at 4 pts for 512px, but 4K costs 13pts
804- 🎨 **Artistic styles**: **Midjourney** excels at creative, artistic, and illustration styles
805- 💡 **Best value**: **SeeDream 4.5** at 5pts offers aspect ratio flexibility; **Nano Banana2** 512px at 4pts for fastest/cheapest
806
807---
808
809## Environment
810
811Base URL: `https://api.imastudio.com`
812
813Required/recommended headers for all `/open/v1/` endpoints:
814
815| Header | Required | Value | Notes |
816|--------|----------|-------|-------|
817| `Authorization` | ✅ | `Bearer ima_your_api_key_here` | API key authentication |
818| `x-app-source` | ✅ | `ima_skills` | Fixed value — identifies skill-originated requests |
819| `x_app_language` | recommended | `en` / `zh` | Product label language; defaults to `en` if omitted |
820
821```
822Authorization: Bearer ima_your_api_key_here
823x-app-source: ima_skills
824x_app_language: en
825```
826
827---
828
829## ⚠️ MANDATORY: Always Query Product List First
830
831> **CRITICAL**: You MUST call `/open/v1/product/list` BEFORE creating any task.
832> The `attribute_id` field is REQUIRED in the create request. If it is `0` or missing, you get:
833> `"Invalid product attribute"` → `"Insufficient points"` → task fails completely.
834> **NEVER construct a create request from the model table alone. Always fetch the product first.**
835
836### Why attribute_id is required
837
838The `attribute_id` uniquely identifies the exact product variant (model + quality tier). The billing and routing system uses it to:
8391. Validate the product is purchasable
8402. Deduct the correct credits via `credit_rules`
8413. Route the request to the right backend model
842
843### How to get attribute_id
844
845```python
846# Step 1: Query product list for the target category
847GET /open/v1/product/list?app=ima&platform=web&category=text_to_image
848
849# Step 2: Walk the V2 tree to find your model (type=3 leaf nodes only)
850for group in response["data"]:
851 for version in group.get("children", []):
852 if version["type"] == "3" and version["model_id"] == target_model_id:
853 attribute_id = version["credit_rules"][0]["attribute_id"]
854 credit = version["credit_rules"][0]["points"]
855 model_version = version["id"] # = version_id
856 model_name = version["name"]
857 form_defaults = {f["field"]: f["value"] for f in version["form_config"]}
858```
859
860### Quick Reference: Known attribute_ids
861
862⚠️ **Production warning**: `attribute_id` and `credit` values change frequently. Always call `/open/v1/product/list` at runtime; table below is pre-queried reference (2026-02-27).
863
864**text_to_image**:
865
866| Model | model_id | attribute_id | credit | Size |
867|-------|----------|-------------|--------|------|
868| **SeeDream 4.5** 🌟 | `doubao-seedream-4.5` | **2341** | 5 pts | Default (adaptive 4k) |
869| **Nano Banana2** (512px) | `gemini-3.1-flash-image` | **4400** | 4 pts | 512px (512×512) |
870| **Nano Banana2** (1K) | `gemini-3.1-flash-image` | **4401** | 6 pts | 1K (1024×1024) |
871| **Nano Banana2** (2K) | `gemini-3.1-flash-image` | **4402** | 10 pts | 2K (2048×2048) |
872| **Nano Banana2** (4K) | `gemini-3.1-flash-image` | **4403** | 13 pts | 4K (4096×4096) |
873| Nano Banana Pro (1K) | `gemini-3-pro-image` | **2399** | 10 pts | 1K (1024×1024) |
874| Nano Banana Pro (2K) | `gemini-3-pro-image` | **2400** | 10 pts | 2K (2048×2048) |
875| Nano Banana Pro (4K) | `gemini-3-pro-image` | **2401** | 18 pts | 4K (4096×4096) |
876
877**image_to_image**:
878
879| Model | model_id | attribute_id | credit | Size |
880|-------|----------|-------------|--------|------|
881| **SeeDream 4.5** 🌟 | `doubao-seedream-4.5` | **1611** | 5 pts | Default (adaptive 4k) |
882| **Nano Banana2** (512px) | `gemini-3.1-flash-image` | **4404** | 4 pts | 512px (512×512) |
883| **Nano Banana2** (1K) | `gemini-3.1-flash-image` | **4405** | 6 pts | 1K (1024×1024) |
884| **Nano Banana2** (2K) | `gemini-3.1-flash-image` | **4406** | 10 pts | 2K (2048×2048) |
885| **Nano Banana2** (4K) | `gemini-3.1-flash-image` | **4407** | 13 pts | 4K (4096×4096) |
886| Nano Banana Pro (1K) | `gemini-3-pro-image` | **2402** | 10 pts | 1K (1024×1024) |
887| Nano Banana Pro (2K) | `gemini-3-pro-image` | **2403** | 10 pts | 2K (2048×2048) |
888| Nano Banana Pro (4K) | `gemini-3-pro-image` | **2404** | 10 pts | 4K (4096×4096) |
889
890⚠️ **Note**: Production has 3 models (SeeDream 4.5 + Nano Banana2 + Nano Banana Pro). All other models mentioned in older documentation are no longer available.
891
892---
893
894## Core Flow
895
896```
8971. GET /open/v1/product/list?app=ima&platform=web&category=<type>
898 → REQUIRED: Get attribute_id, credit, model_version, form_config defaults
899
900[image_to_image only]
9012. Upload input image → get public HTTPS URL
902 → See "Image Upload" section below
903
9043. POST /open/v1/tasks/create
905 → Must include: attribute_id, model_name, model_version, credit, cast, prompt (nested!)
906
9074. POST /open/v1/tasks/detail {task_id: "..."}
908 → Poll every 2–5s until medias[].resource_status == 1
909 → Extract url from completed media
910```
911
912### Common Mistakes (and resulting errors)
913
914| Mistake | Error |
915|---------|-------|
916| `attribute_id` is 0 or missing | `"Invalid product attribute"` → Insufficient points |
917| `attribute_id` outdated (production changed) | Same errors; always query product list first |
918| `prompt` at outer level instead of `parameters.parameters.prompt` | Prompt ignored or error |
919| `cast` missing from inner `parameters` | Billing validation failure |
920| `credit` wrong / missing | Error 6006 |
921| `model_name` or `model_version` missing | Wrong model routing |
922| Skip product list, use hardcoded values | All of the above |
923
924---
925
926## Image Upload (Required for image_to_image)
927
928**The IMA Open API does NOT accept raw bytes or base64 images. All input images must be public HTTPS URLs.**
929
930When a user provides an image (local file, bytes, base64), upload it first using the IMA presigned URL flow — the same flow the IMA frontend uses.
931
932### Two-Step Upload Flow
933
934```
935Step 1: GET /api/rest/oss/getuploadtoken → { ful, fdl }
936Step 2: PUT {ful} with raw image bytes
937 → use fdl (CDN URL) as input_images value
938```
939
940See `ima-all-ai/SKILL.md` → "Image Upload" section for the complete implementation.
941
942### Quick Reference
943
944```python
945# If user provides a URL already → use directly
946if source.startswith("https://"):
947 input_url = source
948
949# If user provides a local file → upload first
950else:
951 token = get_upload_token(uid, ima_token, suffix="jpeg",
952 content_type="image/jpeg", ...)
953 upload_image_to_oss(image_bytes, "image/jpeg", token["ful"])
954 input_url = token["fdl"] # CDN URL → use as input_images
955
956# Then create task
957task_id = create_task("image_to_image", prompt, product,
958 input_images=[input_url], size="4k")
959```
960
961> **CDN**: `https://ima-ga.esxscloud.com/` | **OSS**: `zhubite-imagent-bot.oss-us-east-1.aliyuncs.com`
962
963---
964
965## Supported Task Types
966
967| category | Capability | Input |
968|----------|------------|-------|
969| `text_to_image` | Text → Image | prompt |
970| `image_to_image` | Image → Image | prompt + input image URL |
971
972---
973
974## Detail API status values
975
976| Field | Type | Values |
977|-------|------|--------|
978| **`resource_status`** | int or `null` | `0`=处理中, `1`=可用, `2`=失败, `3`=已删除;`null` 当作 0 |
979| **`status`** | string | `"pending"`, `"processing"`, `"success"`, `"failed"` |
980
981| `resource_status` | `status` | Action |
982|-------------------|----------|--------|
983| `0` or `null` | `pending` / `processing` | Keep polling |
984| `1` | `success` (or `completed`) | Stop when **all** medias are 1; read `url` |
985| `1` | `failed` | Stop, handle error |
986| `2` / `3` | any | Stop, handle error |
987
988> **Important**: Treat `resource_status: null` as 0. Stop only when **all** medias have `resource_status == 1`. Check `status != "failed"` when rs=1.
989
990---
991
992## API 1: Product List
993
994```
995GET /open/v1/product/list?app=ima&platform=web&category=text_to_image
996```
997
998Returns a **V2 tree structure**: `type=2` nodes are model groups, `type=3` nodes are versions (leaves). Only `type=3` nodes contain `credit_rules` and `form_config`.
999
1000```json
1001[
1002 {
1003 "id": "SeeDream",
1004 "type": "2",
1005 "name": "SeeDream",
1006 "model_id": "",
1007 "children": [
1008 {
1009 "id": "doubao-seedream-4-5-251128",
1010 "type": "3",
1011 "name": "SeeDream 4.5",
1012 "model_id": "doubao-seedream-4.5",
1013 "credit_rules": [
1014 { "attribute_id": 2341, "points": 5, "attributes": { "default": "enabled" } }
1015 ],
1016 "form_config": [
1017 { "field": "size", "type": "tags", "value": "4k",
1018 "options": [{"label":"2K","value":"2k"}, {"label":"4K","value":"4k"}] }
1019 ]
1020 }
1021 ]
1022 }
1023]
1024```
1025
1026**How to pick a version for task creation:**
10271. Traverse nodes to find `type=3` leaves (versions)
10282. Use `model_id` and `id` (= `model_version`) from the leaf
10293. Pick `credit_rules[].attribute_id` matching your desired quality/size
10304. Use `form_config[].value` as default `parameters` values
1031
1032---
1033
1034## API 2: Create Task
1035
1036```
1037POST /open/v1/tasks/create
1038```
1039
1040### text_to_image — Verified ✅
1041
1042No image input. `src_img_url: []`, `input_images: []`.
1043
1044```json
1045{
1046 "task_type": "text_to_image",
1047 "enable_multi_model": false,
1048 "src_img_url": [],
1049 "parameters": [{
1050 "attribute_id": 2341,
1051 "model_id": "doubao-seedream-4.5",
1052 "model_name": "SeeDream 4.5",
1053 "model_version": "doubao-seedream-4-5-251128",
1054 "app": "ima",
1055 "platform": "web",
1056 "category": "text_to_image",
1057 "credit": 5,
1058 "parameters": {
1059 "prompt": "a beautiful mountain sunset, photorealistic",
1060 "size": "4k",
1061 "n": 1,
1062 "input_images": [],
1063 "cast": {"points": 5, "attribute_id": 2341}
1064 }
1065 }]
1066}
1067```
1068
1069### image_to_image — Verified ✅
1070
1071```json
1072{
1073 "task_type": "image_to_image",
1074 "enable_multi_model": false,
1075 "src_img_url": ["https://example.com/input.jpg"],
1076 "parameters": [{
1077 "attribute_id": 1611,
1078 "model_id": "doubao-seedream-4.5",
1079 "model_name": "SeeDream 4.5",
1080 "model_version": "doubao-seedream-4-5-251128",
1081 "app": "ima",
1082 "platform": "web",
1083 "category": "image_to_image",
1084 "credit": 5,
1085 "parameters": {
1086 "prompt": "turn into oil painting style",
1087 "size": "4k",
1088 "n": 1,
1089 "input_images": ["https://example.com/input.jpg"],
1090 "cast": {"points": 5, "attribute_id": 1611}
1091 }
1092 }]
1093}
1094```
1095
1096> ⚠️ `size` must be from `form_config` options (e.g. `"2k"`, `"4k"`, `"2048x2048"`). `"adaptive"` is NOT valid for SeeDream 4.5 — causes error 400.
1097> Top-level `src_img_url` **and** `parameters.input_images` must both contain the input image URL.
1098
1099**Key fields**:
1100
1101| Field | Required | Description |
1102|-------|----------|-------------|
1103| `parameters[].credit` | ✅ | Must equal `credit_rules[].points`. Error 6006 if wrong. |
1104| `parameters[].parameters.prompt` | ✅ | Prompt must be nested here, NOT at top level. |
1105| `parameters[].parameters.cast` | ✅ | `{"points": N, "attribute_id": N}` — mirror of credit. |
1106| `parameters[].parameters.n` | ✅ | Number of outputs (usually `1`). |
1107| `parameters[].parameters.input_images` | image_to_image | Array of input image URLs. |
1108| top-level `src_img_url` | image_to_image | Must also contain the input image URL. |
1109
1110Response: `data.id` = task ID for polling.
1111
1112---
1113
1114## API 3: Task Detail (Poll)
1115
1116```
1117POST /open/v1/tasks/detail
1118{"task_id": "<id from create response>"}
1119```
1120
1121Poll every 2–5s. Completed response:
1122
1123```json
1124{
1125 "id": "task_abc",
1126 "medias": [{
1127 "resource_status": 1,
1128 "url": "https://cdn.../output.jpg",
1129 "format": "jpg",
1130 "width": 1024,
1131 "height": 1024
1132 }]
1133}
1134```
1135
1136Output fields: `url`, `width`, `height`, `format` (jpg/png).
1137
1138---
1139
1140## FAQ: Parameter Support & Limitations
1141
1142### Q1: Can I generate 16:9 or 7:3 aspect ratio images?
1143
1144**A:** ✅ **YES! Multiple models now support custom aspect ratios.**
1145
1146**✅ Supported aspect ratios:**
1147- **SeeDream 4.5**: 1:1, 16:9, 9:16, 4:3, 3:4, 2:3, 3:2, 21:9 (via virtual params)
1148- **Nano Banana Pro/2/MAX**: 1:1, 16:9, 9:16, 4:3, 3:4 (native support) 🆕
1149
1150**❌ Not supported:**
1151- **Midjourney**: Fixed 1024×1024 (1:1 only)
1152- **Custom ratios**: 7:3, 8:3, or other non-standard ratios are NOT supported by any model
1153
1154**Workarounds for unsupported ratios:**
11551. **Use video models** (recommended): Generate with video models (e.g., Wan 2.6 text_to_video) that support 16:9, 9:16, 1:1, then extract the first frame as an image.
11562. **Post-processing**: Generate a 1:1 image, then crop/extend to desired aspect ratio.
1157
1158**Model recommendation by aspect ratio need:**
1159- **Standard ratios (16:9, 9:16, 4:3, 3:4)**: Nano Banana Pro/2 (native support, no virtual params)
1160- **Extended ratios (2:3, 3:2, 21:9)**: SeeDream 4.5 only
1161- **Square (1:1)**: Any model (SeeDream, Nano Banana, or Midjourney)
1162
1163### Q2: How do I generate 4K images with Nano Banana Pro?
1164
1165**A:** ✅ **Use the `size` parameter** with the correct `attribute_id`.
1166
1167Nano Banana Pro supports 3 size options via different `credit_rules`:
1168- **1K** (1024×1024): 10 pts, attribute_id `2399` (default)
1169- **2K** (2048×2048): 10 pts, attribute_id `2400`
1170- **4K** (4096×4096): **18 pts**, attribute_id `2401`
1171
1172**Script usage:**
1173```bash
1174python3 ima_image_create.py \
1175 --task-type text_to_image \
1176 --model-id gemini-3-pro-image \
1177 --prompt "your prompt" \
1178 --extra-params '{"size": "4K"}'
1179```
1180
1181The script automatically selects the correct `attribute_id` (2401) when you specify `size: "4K"`.
1182
1183### Q3: Can I generate 8K images?
1184
1185**A:** ❌ **No**. No model currently supports 8K resolution. The maximum available is:
1186- **Nano Banana Pro**: 4K (4096×4096)
1187- **SeeDream 4.5 / 4.0 / 3.0**: 4K (adaptive)
1188- **All others**: ≤ 1280×1280
1189
1190**Workaround**: Generate at maximum resolution (4K), then use external AI upscaling tools (e.g., Real-ESRGAN, Topaz Gigapixel) to upscale to 8K.
1191
1192### Q4: Which models support custom aspect ratios?
1193
1194**A:** 🌟 **Multiple models now support aspect ratios!**
1195
1196**✅ NATIVE support (no virtual params needed):**
1197- **Nano Banana Pro**: 1:1, 16:9, 9:16, 4:3, 3:4 🆕
1198- **Nano Banana2**: 1:1, 16:9, 9:16, 4:3, 3:4 🆕
1199- **Nano Banana MAX**: 1:1, 16:9, 9:16, 4:3, 3:4 🆕
1200
1201**✅ Virtual parameter mapping (SeeDream):**
1202- **SeeDream 4.5**: 1:1, 16:9, 9:16, 4:3, 3:4, 2:3, 3:2, 21:9, 2k, 4k
1203
1204**❌ NOT supported:**
1205- **Midjourney**: Fixed 1024×1024 (1:1) only
1206
1207**SeeDream 4.5 aspect_ratio support (8 ratios):**
1208- `1:1` → 2048×2048 (square, 5 pts)
1209- `16:9` → 2560×1440 (widescreen, 5 pts)
1210- `9:16` → 1440×2560 (vertical/portrait, 5 pts)
1211- `4:3` → 2304×1728 (classic, 5 pts)
1212- `3:4` → 1728×2304 (vertical, 5 pts)
1213- `2:3` → 1664×2496 (portrait, 5 pts)
1214- `3:2` → 2496×1664 (landscape, 5 pts)
1215- `21:9` → 3024×1296 (ultra-wide, 5 pts)
1216- `2k` / `4k` → Adaptive resolution (5 pts)
1217
1218**Nano Banana series native support (5 ratios):**
1219- `1:1`, `16:9`, `9:16`, `4:3`, `3:4`
1220- No virtual params needed, passed directly to API
1221
1222**Usage:**
1223```bash
1224# SeeDream 4.5 (virtual params)
1225python3 ima_image_create.py \
1226 --task-type text_to_image \
1227 --model-id doubao-seedream-4.5 \
1228 --prompt "beautiful landscape" \
1229 --extra-params '{"aspect_ratio": "16:9"}'
1230
1231# Nano Banana Pro (native support)
1232python3 ima_image_create.py \
1233 --task-type text_to_image \
1234 --model-id gemini-3-pro-image \
1235 --prompt "beautiful landscape" \
1236 --extra-params '{"aspect_ratio": "16:9"}'
1237```
1238
1239**How it works (virtual param mapping for SeeDream):**
12401. User provides `aspect_ratio: "16:9"` as input
12412. Script queries product list and finds `is_ui_virtual=true` field
12423. Applies `value_mapping`: `aspect_ratio: "16:9"` → `size: "2560x1440"`
12434. API receives actual parameter: `size: "2560x1440"`
1244
1245**Nano Banana series**: Aspect ratio passed directly, no mapping needed.
1246
1247### Q5: Why does my `aspect_ratio` parameter get ignored?
1248
1249**A:** Two possibilities:
1250
12511. **Model doesn't support it**: Only SeeDream 4.5 and Nano Banana series support custom aspect ratios. Midjourney only supports 1:1 (square).
1252
12532. **Virtual param not available in production**: For SeeDream 4.5, the `is_ui_virtual=true` feature may not be deployed yet. If you get 1:1 square output despite requesting 16:9, the API doesn't have the virtual parameter mapping active.
1254
1255**Solution:**
1256- Use **SeeDream 4.5** or **Nano Banana Pro/2/MAX** for aspect ratio needs
1257- Use **video models** with custom aspect ratio, extract first frame
1258- Post-process: Crop or extend the image manually
1259
1260### Q6: What's the difference between `size` and `resolution`?
1261
1262**A:**
1263- **`size`**: For Nano Banana Pro only. Options: "1K", "2K", "4K". Controls output resolution via different `attribute_id`s.
1264- **`resolution`**: Used in **video models** (e.g., "1080P", "720P", "4K"). Not applicable to text_to_image models.
1265
1266### Q7: Can I control the aspect ratio after generation?
1267
1268**A:** Not directly in this skill. Options:
12691. **Crop**: Take the center/top/bottom portion of the square image to get desired ratio.
12702. **Extend (inpainting)**: Use image editing APIs to extend the image to fill the target aspect ratio.
12713. **Video workaround**: Use video models with desired aspect ratio, extract first frame.
1272
1273---
1274
1275## Common Mistakes
1276
1277| Mistake | Fix |
1278|---------|-----|
1279| Using `attribute_id` not from `credit_rules` | Always fetch product list first |
1280| Placing `prompt` at param top-level | `prompt` must be inside `parameters[].parameters` |
1281| Missing `app` / `platform` in parameters | Required — use `ima` / `web` |
1282| Wrong `credit` value | Must exactly match `credit_rules[].points` (error 6006) |
1283| `size: "adaptive"` for SeeDream 4.5 i2i | Use values from `form_config` options only |
1284| Missing image in both `src_img_url` and `input_images` | Both fields required for image_to_image |
1285
1286---
1287
1288## Python Example
1289
1290```python
1291import time
1292import requests
1293
1294BASE_URL = "https://api.imastudio.com"
1295API_KEY = "ima_your_key_here"
1296HEADERS = {
1297 "Authorization": f"Bearer {API_KEY}",
1298 "Content-Type": "application/json",
1299 "x-app-source": "ima_skills",
1300 "x_app_language": "en",
1301}
1302
1303
1304def get_products(category: str) -> list:
1305 """Returns flat list of type=3 version nodes from V2 tree."""
1306 r = requests.get(
1307 f"{BASE_URL}/open/v1/product/list",
1308 headers=HEADERS,
1309 params={"app": "ima", "platform": "web", "category": category},
1310 )
1311 r.raise_for_status()
1312 nodes = r.json()["data"]
1313 versions = []
1314 for node in nodes:
1315 for child in node.get("children") or []:
1316 if child.get("type") == "3":
1317 versions.append(child)
1318 for gc in child.get("children") or []:
1319 if gc.get("type") == "3":
1320 versions.append(gc)
1321 return versions
1322
1323
1324def create_image_task(task_type: str, prompt: str, product: dict, input_images: list = None, **extra) -> str:
1325 """Returns task_id. task_type: 'text_to_image' or 'image_to_image'."""
1326 input_images = input_images or []
1327 rule = product["credit_rules"][0]
1328 form_defaults = {f["field"]: f["value"] for f in product.get("form_config", []) if f.get("value") is not None}
1329
1330 nested_params = {
1331 "prompt": prompt,
1332 "n": 1,
1333 "input_images": input_images,
1334 "cast": {"points": rule["points"], "attribute_id": rule["attribute_id"]},
1335 **form_defaults,
1336 }
1337 nested_params.update({k: v for k, v in extra.items() if k in ("size",)})
1338
1339 body = {
1340 "task_type": task_type,
1341 "enable_multi_model": False,
1342 "src_img_url": input_images,
1343 "parameters": [{
1344 "attribute_id": rule["attribute_id"],
1345 "model_id": product["model_id"],
1346 "model_name": product["name"],
1347 "model_version": product["id"],
1348 "app": "ima",
1349 "platform": "web",
1350 "category": task_type,
1351 "credit": rule["points"],
1352 "parameters": nested_params,
1353 }],
1354 }
1355 r = requests.post(f"{BASE_URL}/open/v1/tasks/create", headers=HEADERS, json=body)
1356 r.raise_for_status()
1357 return r.json()["data"]["id"]
1358
1359
1360def poll(task_id: str, interval: int = 3, timeout: int = 300) -> dict:
1361 deadline = time.time() + timeout
1362 while time.time() < deadline:
1363 r = requests.post(f"{BASE_URL}/open/v1/tasks/detail", headers=HEADERS, json={"task_id": task_id})
1364 r.raise_for_status()
1365 task = r.json()["data"]
1366 medias = task.get("medias", [])
1367 if medias:
1368 if any(m.get("status") == "failed" for m in medias):
1369 raise RuntimeError(f"Task failed: {task_id}")
1370 rs = lambda m: m.get("resource_status") if m.get("resource_status") is not None else 0
1371 if any(rs(m) == 2 for m in medias):
1372 raise RuntimeError(f"Task failed: {task_id}")
1373 if all(rs(m) == 1 for m in medias):
1374 return task
1375 time.sleep(interval)
1376 raise TimeoutError(f"Task timed out: {task_id}")
1377
1378
1379# text_to_image (SeeDream 4.5)
1380products = get_products("text_to_image")
1381task_id = create_image_task("text_to_image", "mountain sunset, photorealistic", products[0])
1382result = poll(task_id)
1383print(result["medias"][0]["url"])
1384
1385# text_to_image with Midjourney (artistic style)
1386products = get_products("text_to_image")
1387midjourney = next(p for p in products if p["model_id"] == "midjourney")
1388task_id = create_image_task("text_to_image", "fantasy castle, impressionist painting style", midjourney)
1389result = poll(task_id, interval=8) # Midjourney: poll every 8s
1390print(result["medias"][0]["url"])
1391
1392# text_to_image with aspect ratio (Nano Banana Pro - native support)
1393products = get_products("text_to_image")
1394nano_pro = next(p for p in products if p["model_id"] == "gemini-3-pro-image")
1395task_id = create_image_task("text_to_image", "beautiful landscape", nano_pro, aspect_ratio="16:9")
1396result = poll(task_id)
1397print(result["medias"][0]["url"])
1398
1399# image_to_image (size must match form_config options, NOT "adaptive")
1400products = get_products("image_to_image")
1401seedream_i2i = next(p for p in products if p["model_id"] == "doubao-seedream-4.5")
1402task_id = create_image_task(
1403 "image_to_image", "turn into oil painting style", seedream_i2i,
1404 input_images=["https://example.com/input.jpg"],
1405 size="4k",
1406)
1407result = poll(task_id)
1408print(result["medias"][0]["url"])
1409
1410# image_to_image with Midjourney (artistic style transfer)
1411products = get_products("image_to_image")
1412midjourney = next(p for p in products if p["model_id"] == "midjourney")
1413task_id = create_image_task(
1414 "image_to_image", "anime style, vibrant colors", midjourney,
1415 input_images=["https://example.com/portrait.jpg"],
1416)
1417result = poll(task_id, interval=8) # Midjourney: poll every 8s
1418print(result["medias"][0]["url"])
1419```