FLUX.2-pro Image Generation
简介
FLUX.2-pro Image Generation
原始描述
Generate images using Black Forest Labs FLUX.2-pro via Azure AI Foundry. Use when asked to create, generate, or produce images, illustrations, photos, artwor...
通过你的 Agent 添加
安装目录:flux-image-gen/(目录名取自 SKILL.md 的 frontmatter name,不是 URL 里的 slug)。
点「快速安装」复制一段指令贴给你的 Agent:它会先下载到 /tmp、把文件清单和校验值给你看,你确认之后才解压安装。不会一步装完、也不改系统其它位置。
或者手动安装
包是「根级 SKILL.md + 作者附带的文件」,解压到上面的 <slug>/ 目录即可;
目录名不用换,也不要把包直接解压到 skills 根目录。
技能申请的权限由作者决定:装之前先看清单里有没有脚本、它会读写什么。
技能正文
name: flux-image-gen
description: Generate images using Black Forest Labs FLUX.2-pro via Azure AI Foundry. Use when asked to create, generate, or produce images, illustrations, photos, artwork, posters, or visual content. Supports custom dimensions, seeds for reproducibility, and Chinese text overlay via Node.js Canvas. Requires FLUX_ENDPOINT and FLUX_API_KEY environment variables.
FLUX.2-pro Image Generation
Generate high-quality images from text prompts using FLUX.2-pro on Azure AI Foundry.
Setup
Set environment variables (typically in OpenClaw config or shell profile):
export FLUX_ENDPOINT="https://<resource>.services.ai.azure.com/providers/blackforestlabs/v1/flux-2-pro?api-version=preview"
export FLUX_API_KEY="<your-api-key>"
Quick Generation
Use the bundled script:
node scripts/generate.mjs --prompt "a red fox in autumn forest" --output fox.png
node scripts/generate.mjs --prompt "cute robot" --width 1440 --height 816 --output robot.png
Direct API Call
When the script isn't suitable, call the API directly:
curl -s -X POST "$FLUX_ENDPOINT" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $FLUX_API_KEY" \
-d '{"prompt":"a cat","width":1024,"height":1024,"n":1,"model":"FLUX.2-pro"}' \
| node -e "process.stdin.on('data',d=>{const j=JSON.parse(d);require('fs').writeFileSync('out.png',Buffer.from(j.data[0].b64_json,'base64'))})"
Critical parameters: "n": 1 and "model": "FLUX.2-pro" are mandatory. Omitting them causes HTTP 500.
Chinese Text Overlay
FLUX cannot render CJK characters. Overlay text with Node.js Canvas:
import { createCanvas, loadImage, registerFont } from "canvas";
registerFont("NotoSansCJK-Bold.otf", { family: "NotoSansCJK" });
const img = await loadImage("base.png");
const canvas = createCanvas(img.width, img.height);
const ctx = canvas.getContext("2d");
ctx.drawImage(img, 0, 0);
ctx.font = 'bold 48px "NotoSansCJK"';
ctx.fillStyle = "#ffffff";
ctx.fillText("你好世界", 100, 100);
Requires: npm install canvas + a CJK font file (e.g., NotoSansCJK-Bold.otf).
Best Practices
- Serialize requests — avoid parallel API calls; use sequential generation
- Set 180s timeout — generation can take 30–120 seconds
- Prompt in English — FLUX works best with English prompts
- Content filter — avoid violent, sexual, or otherwise filtered content in prompts
- Print quality — use 1240×1754 for A3, scale up as needed
API Reference
See references/api.md for full request/response schema and size options.
正文来自原始发布页, 版权归作者所有,许可未标注。 权利人认为有不妥,可申请下架。