← 返回
未分类 Key

Kie-image-gen

Generate and edit images using KIE.ai's gpt-image-2 models (text-to-image and image-to-image). Use when the user wants to: generate images from text descriptions, create AI art, edit/transform existing images based on prompts, apply style transfers, or any request involving AI image generation via KIE.ai. Triggers: 生成图片、AI生图、文生图、图生图、generate image、text to image、image to image、KIE生图、GPT图片生成
Generate and edit images using KIE.ai's gpt-image-2 models (text-to-image and image-to-image). Use when the user wants to: generate images from text descriptions, create AI art, edit/transform existing images based on prompts, apply style transfers, or any request involving AI image generation via KIE.ai. Triggers: 生成图片、AI生图、文生图、图生图、generate image、text to image、image to image、KIE生图、GPT图片生成
user_9f83b00e
未分类 community v1.0.0 1 版本 99038.5 Key: 需要
★ 0
Stars
📥 103
下载
💾 2
安装
1
版本
#latest

概述

KIE.ai Image Generation

Generate images from text prompts or transform existing images using KIE.ai's GPT-Image-2 models.

Prerequisites

  • KIE.ai API Key: Required for all operations. Obtain from https://kie.ai
  • The API key must be stored in environment variable KIE_API_KEY or provided by the user

Quick Start

Text-to-Image

python scripts/kie_image.py --mode text2img --prompt "YOUR_PROMPT" --api-key YOUR_KEY --output ./output

Image-to-Image

python scripts/kie_image.py --mode img2img --prompt "YOUR_PROMPT" --input-urls "URL1,URL2" --api-key YOUR_KEY --output ./output

Workflow

Step 1: Determine Mode

  • text2img: User provides a text prompt only → use gpt-image-2-text-to-image
  • img2img: User provides source images + text prompt → use gpt-image-2-image-to-image

If the user provides reference images (uploaded files, URLs, or paths), use img2img mode.

Step 2: Prepare Parameters

| Parameter | text2img | img2img | Notes |

|-----------|----------|---------|-------|

| prompt | Required | Required | Describe the desired output image |

| input_urls | N/A | Required | 1+ image URLs (comma-separated) |

| aspect_ratio | Optional | Optional | auto, 1:1, 16:9, 9:16, 4:3, 3:4 |

| nsfw_checker | Optional | Optional | Default true; set false to disable content filter |

Prompt tips:

  • Be specific and descriptive for best results
  • Include style, lighting, composition details
  • For img2img, describe how the output should relate to the input

Aspect ratio guidance:

  • auto (default): model decides
  • 1:1: square, good for portraits/icons
  • 16:9: landscape, good for wide scenes
  • 9:16: portrait, good for phone screens/posters
  • 4:3/3:4: standard photo ratios

Step 3: Execute the Script

The Python script (scripts/kie_image.py) handles:

  1. Creating the task on KIE.ai
  2. Polling for completion (up to 5 minutes)
  3. Downloading generated images to the output directory
  4. Outputting a JSON result with file paths

API key resolution order:

  1. --api-key CLI argument
  2. KIE_API_KEY environment variable
  3. Ask the user for their key

Step 4: Present Results

The script outputs JSON on stdout:

{
  "task_id": "task_gptimage_xxx",
  "model": "gpt-image-2-text-to-image",
  "image_urls": ["https://..."],
  "downloaded_files": ["/path/to/image.png"],
  "status": "success"
}

Show the generated image(s) to the user via open_result_view or preview_url.

Handling Source Images for img2img

When the user provides local image files for img2img mode:

  • Local files must be uploaded to get public URLs first
  • Use image hosting services (imgur, etc.) to get publicly accessible URLs
  • The input_urls parameter requires HTTP/HTTPS URLs, not local paths

Error Handling

  • Task creation fails: Check API key validity, model name, and parameter format
  • Polling timeout: Task may still be processing; user can retry later with the task ID
  • No image URLs in result: The API response structure may vary; inspect the full output
  • Download fails: Image URLs may be temporary; download immediately after task completion

API Reference

See references/api_reference.md for detailed API documentation.

版本历史

共 1 个版本

  • v1.0.0 Initial release 当前
    2026-04-25 01:12 安全 安全

安全检测

腾讯云安全 (Keen)

安全,无风险
查看报告

腾讯云安全 (Sanbu)

安全,无风险
查看报告

🔗 相关推荐

developer-tools

Github

steipete
使用 `gh` CLI 与 GitHub 交互,通过 `gh issue`、`gh pr`、`gh run` 和 `gh api` 管理议题、PR、CI 运行及高级查询。
★ 668 📥 324,236
ai-intelligence

ontology

oswalpalash
类型化知识图谱,用于结构化智能体记忆与可组合技能。支持创建/查询实体(人员、项目、任务、事件、文档)及关联...
★ 712 📥 243,903
security-compliance

Skill Vetter

spclaudehome
AI智能体技能安全预审工具。安装ClawdHub、GitHub等来源技能前,检查风险信号、权限范围及可疑模式。
★ 1,215 📥 266,591