Krea AI — Image, Video & Enhancement Generation
Generate images, videos, upscale/enhance images, and train LoRA styles using the Krea.ai API. Supports 20+ image models (Flux, Imagen, GPT Image, Ideogram, Seedream...), 7 video models (Kling, Veo, Hailuo, Wan), and 3 upscalers (Topaz up to 22K).
IMPORTANT: Do NOT invent model names. Run list_models.py to get the live list of models, CU costs, and accepted parameters from the Krea API's OpenAPI spec. All scripts resolve models dynamically from the spec — there are no hardcoded endpoint tables. Scripts also accept full endpoint paths from list_models.py --json output (e.g. --model /generate/image/google/imagen-4-ultra).
Usage
Scripts are in the scripts/ directory alongside this file. Run them with uv run from the user's working directory so output files are saved where the user expects.
Generate image:
CODEBLOCK0
Generate video:
CODEBLOCK1
Enhance/upscale image:
CODEBLOCK2
Train a LoRA style:
CODEBLOCK3
List available models:
CODEBLOCK4
Run a multi-step pipeline:
CODEBLOCK5
Check job status:
CODEBLOCK6
Important: Always run from the user's current working directory so files are saved where the user is working.
Default Workflow (draft → iterate → final)
Goal: fast iteration without burning CU on expensive models until the prompt is right.
- - Draft (cheap/fast): use
--model z-image or --model flux-1-dev (3-5 CU, ~5s) for quick iteration
CODEBLOCK7
- - Iterate: adjust prompt, keep trying with cheap models
- - Final (high quality): switch to
--model gpt-image or INLINECODE8
CODEBLOCK8
Available Models
Models, CU costs, and accepted body fields are fetched live from the Krea API's OpenAPI spec (/openapi.json). Run list_models.py to see what's currently available:
CODEBLOCK9
Short aliases (e.g. flux for flux-1-dev) are maintained for convenience. The scripts resolve them automatically via the spec. If a model isn't in the alias list, pass the full OpenAPI model ID or endpoint path.
Model selection guidance
Map user requests for images:
- - "fast", "quick", "cheap" →
flux-1-dev or INLINECODE14 - "high quality", "best" →
nano-banana-pro or INLINECODE16 - "text in image", "typography" → INLINECODE17
- "photorealistic" →
seedream-4 or INLINECODE19 - No preference → INLINECODE20
Map user requests for video:
- - "fast" → INLINECODE21
- "cinematic", "high quality" → INLINECODE22
- "with sound", "with audio" →
veo-3 with INLINECODE24 - No preference → INLINECODE25
Enhancers: topaz-standard-enhance (faithful upscaling, default), topaz-generative-enhance (creative enhancement), topaz-bloom-enhance (adding creative details).
Image Generation Parameters
| Param | Description | Default |
|---|
| INLINECODE29 | Model ID or alias (run list_models.py) | INLINECODE30 |
| INLINECODE31 |
Text description (required) | — |
|
--filename | Output filename (required) | — |
|
--width | Width in pixels (512-4096) | 1024 |
|
--height | Height in pixels (512-4096) | 1024 |
|
--aspect-ratio | Aspect ratio (1:1, 16:9, 9:16, 4:3, 3:2, etc.) | — |
|
--resolution | 1K, 2K, 4K (nano-banana models) | — |
|
--seed | Seed for reproducibility | — |
|
--image-url | Input image URL or local file path for image-to-image | — |
|
--style-id | LoRA style ID to apply | — |
|
--style-strength | LoRA strength (-2 to 2) | 1.0 |
|
--batch-size | Number of images (1-4) | 1 |
|
--steps | Inference steps, 1-100 (flux models) | 25 |
|
--guidance-scale | Guidance scale, 0-24 (flux models) | 3 |
|
--quality | low/medium/high/auto (gpt-image) | auto |
|
--output-dir | Output directory | cwd |
|
--api-key | Krea API token | — |
Video Generation Parameters
| Param | Description | Default |
|---|
| INLINECODE47 | Model ID or alias (run list_models.py) | INLINECODE48 |
| INLINECODE49 |
Text description (required) | — |
|
--filename | Output filename (required) | — |
|
--duration | Duration in seconds | 5 |
|
--aspect-ratio | 16:9, 9:16, 1:1 | 16:9 |
|
--start-image | URL or local file path for image-to-video | — |
|
--end-image | End frame URL (kling only) | — |
|
--resolution | 720p, 1080p (veo only) | 720p |
|
--mode | std, pro (kling only) | std |
|
--generate-audio | Generate audio (veo-3 only) | false |
|
--output-dir | Output directory | cwd |
|
--api-key | Krea API token | — |
Enhancement Parameters
| Param | Description | Default |
|---|
| INLINECODE60 | Enhancer ID (run list_models.py --type enhance) | INLINECODE61 |
| INLINECODE62 |
Source image URL or local file path (required) | — |
|
--filename | Output filename (required) | — |
|
--width | Target width (required) | — |
|
--height | Target height (required) | — |
|
--enhancer-model | Sub-model variant | Standard V2 |
|
--creativity | 1-6 (generative) or 1-9 (bloom) | — |
|
--face-enhancement | Enable face enhancement | false |
|
--sharpen | Sharpening 0-1 | — |
|
--denoise | Denoising 0-1 | — |
|
--scaling-factor | Upscaling factor 1-32 | — |
|
--output-format | png, jpg, webp | png |
|
--output-dir | Output directory | cwd |
|
--api-key | Krea API token | — |
LoRA Training Parameters
| Param | Description | Default |
|---|
| INLINECODE75 | Style name (required) | — |
| INLINECODE76 |
Base model: flux
dev, fluxschnell, wan, qwen, z-image |
flux_dev |
|
--type | LoRA type: Style, Object, Character, Default |
Style |
|
--urls | Training image URLs (space-separated) | — |
|
--urls-file | Text file with one URL per line | — |
|
--trigger-word | Trigger word to activate the LoRA in prompts | — |
|
--learning-rate | Learning rate | 0.0001 |
|
--max-train-steps | Max training steps | 1000 |
|
--batch-size | Training batch size | 1 |
|
--timeout | Polling timeout in seconds | 3600 |
|
--skip-validation | Skip URL HEAD-check validation | false |
|
--output-dir | Directory to save training manifest | — |
|
--api-key | Krea API token | — |
Training requires 3-2000 images. The script validates all URLs before submitting. Training takes 15-45 minutes. On completion, the style ID is printed to stdout and a training-manifest.json is saved if --output-dir is set.
Use the style ID with --style-id in generate_image.py:
CODEBLOCK10
API Key
Scripts check for API key in this order:
- 1.
--api-key argument (use if user provided key in chat) - INLINECODE95 environment variable
If neither is available, the script exits with an error message.
Preflight + Common Failures
Preflight:
- -
command -v uv (must exist) - INLINECODE97 (or pass
--api-key)
Common failures:
- -
Error: No API key → set KREA_API_TOKEN or pass INLINECODE101 - INLINECODE102 → top up compute units at https://krea.ai/settings/billing
- INLINECODE103 → model needs a paid plan upgrade at https://krea.ai/settings/billing
- INLINECODE104 → concurrent job limit reached; scripts auto-retry up to 3 times with backoff
- INLINECODE105 → check prompt for content moderation issues, try different wording
Filename Generation
Generate filenames with the pattern: INLINECODE106
- - Timestamp: current date/time in
yyyy-mm-dd-hh-mm-ss (24h format) - Name: descriptive lowercase text with hyphens (1-5 words)
- Extension:
.png for images, .mp4 for videos
Examples:
- - Prompt "A cyberpunk cat" → INLINECODE110
- Prompt "waves on a beach" → INLINECODE111
Prompt Handling
For generation: Pass user's description as-is to --prompt. Only rework if clearly insufficient.
For image-to-image: Use --image-url with the source image and describe the desired transformation in --prompt.
For video from image: Use --start-image with the source image and describe the desired motion/action in --prompt.
Preserve user's creative intent in all cases.
Output
- - Scripts download the result and save it to the current directory (or
--output-dir) - Script outputs the full path to the generated file
- Do not read the image/video back — just inform the user of the saved path
- If
--batch-size > 1, files are saved as name-1.png, name-2.png, etc.
Examples
Quick draft image:
CODEBLOCK11
High quality final:
CODEBLOCK12
Image-to-image edit:
CODEBLOCK13
Generate video:
CODEBLOCK14
Upscale image to 4K:
CODEBLOCK15
Train a LoRA style:
CODEBLOCK16
List models:
CODEBLOCK17
Pipelines (Multi-Step Workflows)
For multi-step workflows (generate → enhance → animate, fanout branching, template variables, parallel execution, resume, dry-run), see PIPELINES.md.
Quick example:
CODEBLOCK18
Krea AI — 图像、视频与增强生成
使用 Krea.ai API 生成图像、视频、放大/增强图像以及训练 LoRA 风格。支持 20+ 图像模型(Flux、Imagen、GPT Image、Ideogram、Seedream...)、7 个视频模型(Kling、Veo、Hailuo、Wan)和 3 个放大工具(Topaz 最高支持 22K)。
重要提示: 请勿自行编造模型名称。运行 listmodels.py 从 Krea API 的 OpenAPI 规范中获取实时的模型列表、CU 成本和接受的参数。所有脚本均从规范中动态解析模型——不存在硬编码的端点表。脚本也接受 listmodels.py --json 输出的完整端点路径(例如 --model /generate/image/google/imagen-4-ultra)。
使用方法
脚本位于此文件旁边的 scripts/ 目录中。使用 uv run 从用户的工作目录运行,以便输出文件保存在用户期望的位置。
生成图像:
bash
uv run ~/.codex/skills/krea/scripts/generate_image.py --prompt 你的描述 --filename output.png [--model nano-banana-2] [--width 1024] [--height 1024] [--api-key KEY]
生成视频:
bash
uv run ~/.codex/skills/krea/scripts/generate_video.py --prompt 你的描述 --filename output.mp4 [--model veo-3.1-fast] [--duration 5] [--aspect-ratio 16:9] [--api-key KEY]
增强/放大图像:
bash
uv run ~/.codex/skills/krea/scripts/enhance_image.py --image-url https://... --filename upscaled.png --width 4096 --height 4096 [--enhancer topaz-standard-enhance] [--api-key KEY]
训练 LoRA 风格:
bash
uv run ~/.codex/skills/krea/scripts/trainstyle.py --name my-style --urls-file images.txt [--model fluxdev] [--type Style] [--trigger-word mystyle] [--api-key KEY]
列出可用模型:
bash
uv run ~/.codex/skills/krea/scripts/list_models.py [--type image|video|enhance]
运行多步骤流水线:
bash
uv run ~/.codex/skills/krea/scripts/pipeline.py --pipeline pipeline.json [--api-key KEY]
检查任务状态:
bash
uv run ~/.codex/skills/krea/scripts/get_job.py --job-id uuid [--api-key KEY]
重要提示: 始终从用户当前工作目录运行,以便文件保存在用户正在工作的位置。
默认工作流程(草稿 → 迭代 → 最终版)
目标:在提示词完善之前,避免在昂贵模型上消耗 CU,实现快速迭代。
- - 草稿(廉价/快速): 使用 --model z-image 或 --model flux-1-dev(3-5 CU,约 5 秒)进行快速迭代
bash
uv run ~/.codex/skills/krea/scripts/generate_image.py --prompt <草稿提示词> --filename yyyy-mm-dd-hh-mm-ss-draft.png --model flux-1-dev
- - 最终版(高质量): 切换到 --model gpt-image 或 --model nano-banana-pro
bash
uv run ~/.codex/skills/krea/scripts/generate_image.py --prompt <最终提示词> --filename yyyy-mm-dd-hh-mm-ss-final.png --model nano-banana-pro
可用模型
模型、CU 成本和接受的请求体字段均从 Krea API 的 OpenAPI 规范(/openapi.json)实时获取。运行 list_models.py 查看当前可用的内容:
bash
uv run ~/.codex/skills/krea/scripts/list_models.py # 所有模型及参数
uv run ~/.codex/skills/krea/scripts/list_models.py --type image # 仅图像模型
uv run ~/.codex/skills/krea/scripts/list_models.py --json # 机器可读格式
为方便使用,维护了简短别名(例如 flux 代表 flux-1-dev)。脚本通过规范自动解析这些别名。如果模型不在别名列表中,请传递完整的 OpenAPI 模型 ID 或端点路径。
模型选择指南
根据用户请求映射图像模型:
- - 快速、迅速、廉价 → flux-1-dev 或 z-image
- 高质量、最佳 → nano-banana-pro 或 gpt-image
- 图像中的文字、排版 → ideogram-3
- 照片级真实感 → seedream-4 或 nano-banana-pro
- 无偏好 → nano-banana-2
根据用户请求映射视频模型:
- - 快速 → hailuo-2.3
- 电影感、高质量 → veo-3.1
- 带声音、带音频 → veo-3 配合 --generate-audio
- 无偏好 → veo-3.1-fast
增强器: topaz-standard-enhance(忠实放大,默认)、topaz-generative-enhance(创意增强)、topaz-bloom-enhance(添加创意细节)。
图像生成参数
| 参数 | 描述 | 默认值 |
|---|
| --model | 模型 ID 或别名(运行 list_models.py) | nano-banana-2 |
| --prompt |
文本描述(必填) | — |
| --filename | 输出文件名(必填) | — |
| --width | 宽度(像素,512-4096) | 1024 |
| --height | 高度(像素,512-4096) | 1024 |
| --aspect-ratio | 宽高比(1:1、16:9、9:16、4:3、3:2 等) | — |
| --resolution | 1K、2K、4K(nano-banana 模型) | — |
| --seed | 用于可复现性的随机种子 | — |
| --image-url | 输入图像 URL 或本地文件路径(用于图生图) | — |
| --style-id | 要应用的 LoRA 风格 ID | — |
| --style-strength | LoRA 强度(-2 到 2) | 1.0 |
| --batch-size | 图像数量(1-4) | 1 |
| --steps | 推理步数,1-100(flux 模型) | 25 |
| --guidance-scale | 引导尺度,0-24(flux 模型) | 3 |
| --quality | low/medium/high/auto(gpt-image) | auto |
| --output-dir | 输出目录 | cwd |
| --api-key | Krea API 令牌 | — |
视频生成参数
| 参数 | 描述 | 默认值 |
|---|
| --model | 模型 ID 或别名(运行 list_models.py) | veo-3.1-fast |
| --prompt |
文本描述(必填) | — |
| --filename | 输出文件名(必填) | — |
| --duration | 时长(秒) | 5 |
| --aspect-ratio | 16:9、9:16、1:1 | 16:9 |
| --start-image | 起始图像 URL 或本地文件路径(用于图生视频) | — |
| --end-image | 结束帧 URL(仅 kling) | — |
| --resolution | 720p、1080p(仅 veo) | 720p |
| --mode | std、pro(仅 kling) | std |
| --generate-audio | 生成音频(仅 veo-3) | false |
| --output-dir | 输出目录 | cwd |
| --api-key | Krea API 令牌 | — |
增强参数
增强器 ID(运行 list_models.py --type