在 OpenClaw 中使用 Flux 2。
Black Forest Labs 的 Flux 2 提供两个质量层级——Pro 以每张 5 美分实现快速、经济的生成,Flex 提供更高保真度的输出。两者都支持文生图和多源 remix,分辨率可选 1k 或 2k。OpenClaw agent 通过与聊天相同的 RunAPI 密钥调用它。
使用 RunAPI 通过 Flux 2 Pro 生成图像。
要求:
- 调用位于 https://runapi.ai/v1/text_to_image 的 RunAPI text_to_image 端点
- 将 model 设置为 "flux-2-pro-text-to-image"
- 使用 RUNAPI_API_KEY 环境变量进行授权
- 可选地将 output_resolution 设为 "1k" 或 "2k",并通过 aspect_ratio 控制尺寸
- 响应是异步的——轮询任务状态端点直到任务完成,然后获取图像 URL
curl -X POST https://runapi.ai/v1/text_to_image \
-H "Authorization: Bearer $RUNAPI_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "flux-2-pro-text-to-image",
"prompt": "a ceramic vase with dried flowers on a linen tablecloth, natural window light, 35mm film grain",
"aspect_ratio": "3:4",
"output_resolution": "2k"
}'
{
"task_id": "tsk_abc123",
"status": "pending",
"model": "flux-2-pro-text-to-image"
}
三步在 OpenClaw 中使用 Flux 2
Configure RunAPI
Set the RUNAPI_API_KEY environment variable. If you already configured RunAPI as an OpenClaw provider for chat, the same key works for Flux 2 image generation — no extra setup needed.
export RUNAPI_API_KEY=runapi_xxx
Call Flux 2
Send a POST request to the text_to_image endpoint with model set to flux-2-pro-text-to-image. Include a prompt, and optionally set aspect_ratio (1:1, 4:3, 16:9, etc.) and output_resolution (1k or 2k). For multi-source remixing, use the remix_image endpoint with source_image_urls instead.
text_to_image
Get the result
The endpoint returns a task ID. Poll the task status endpoint until the status changes to completed, then retrieve the generated image URL from the response. RunAPI SDKs and the CLI handle polling automatically.
task_id: tsk_abc123
Flux 2 API 参数
| 参数 | 类型 | 说明 |
|---|---|---|
model |
string |
Required. flux-2-pro-text-to-image, flux-2-flex-text-to-image, flux-2-pro-remix-image, or flux-2-flex-remix-image. |
prompt |
string |
Text description of the image to generate. |
aspect_ratio |
string |
Optional. Output aspect ratio: 1:1, 4:3, 3:4, 16:9, 9:16, 3:2, or 2:3. Remix endpoints also accept auto. |
output_resolution |
string |
Optional. 1k (default) or 2k. Higher resolution costs more per image. |
source_image_urls |
array |
Required for remix_image. Array of source image URLs to blend or transform. |
callback_url |
string |
Optional. Webhook URL for async completion notification. |
OpenClaw 上的 Flux 2 是什么?
Flux 2 由 Black Forest Labs 出品,是生产级图像模型,其材质保真度真的可以以假乱真。它支持多参考条件和 400 万像素输出,无需微调即可获得品牌一致的效果。OpenClaw agent 通过 RunAPI 的 text_to_image 端点调用它,使用与聊天相同的 API key。
Flux 2 使用场景
照片级产品摄影
生成以假乱真的产品摄影图用于电商目录、广告或品牌内容,无需实体拍摄,材质保真度表现出色。
一致角色与人物生成
使用多参考条件在一系列图像中生成保持相同外观的品牌代言人或角色,无需对每个输出进行手工调整。
高分辨率背景与场景
以 400 万像素输出生成电影感背景、建筑场景和环境图像,细节精度足以用于大幅印刷或视频制作。
Flux 2 + OpenClaw 常见问题
Pro is the faster, more affordable tier at 5 cents per 1k image. Flex produces higher-fidelity output at 14 cents per 1k image. Both share the same API parameters and support text_to_image and remix_image endpoints.
Users report Flux 2 matches or beats Midjourney on photorealism and material fidelity, with the advantage that it runs through a standard API endpoint rather than a Discord bot. It has caught up on text rendering too, though Ideogram V3 still leads on small-point typography.
Yes. Each variant bills per image with resolution-based pricing. For example, Flux 2 Pro costs 5 cents at 1k and 7 cents at 2k. Flux 2 Flex costs 14 cents at 1k and 24 cents at 2k. Check the RunAPI pricing page for current rates.
Flux Kontext specializes in text-guided editing and character consistency with a single input image. Flux 2 focuses on text-to-image generation and multi-source remixing with Pro/Flex quality tiers and selectable output resolution. Both are by Black Forest Labs and available through the same RunAPI key.
Async. The API returns a task ID immediately. Poll the task status endpoint or set a callback_url webhook to receive the completed image URL. RunAPI SDKs and the CLI handle polling automatically.