OPENCLAW + FLUX KONTEXT

在 OpenClaw 中使用 Flux Kontext。

Flux Kontext 由 Black Forest Labs 出品,支持文字引导的图像编辑和生成,并保持角色一致性。OpenClaw agent 通过 RunAPI 调用它,与聊天使用相同的 API key——发送 prompt,获取图像 URL。

一个 API key · 文生图端点 · 异步任务轮询
Use RunAPI to generate an image with Flux Kontext Pro.

Requirements:
- Call the RunAPI text_to_image endpoint at https://runapi.ai/v1/text_to_image
- Set model to "flux-kontext-pro"
- Use the RUNAPI_API_KEY environment variable for authorization
- The response is async — poll the task status endpoint until the task completes, then retrieve the image 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-kontext-pro",
    "prompt": "a matte-black water bottle on a beige stone surface, soft side light, studio photography"
  }'
{
  "task_id": "tsk_abc123",
  "status": "pending",
  "model": "flux-kontext-pro"
}
复制 curl 命令进行测试 flux-kontext
工作原理

三步在 OpenClaw 中使用 Flux Kontext

1

配置 RunAPI

设置 RUNAPI_API_KEY 环境变量。如果你已经在 OpenClaw 中将 RunAPI 配置为 provider 用于聊天,同一个 key 也适用于图像生成,无需额外配置。

export RUNAPI_API_KEY=runapi_xxx
2

调用 Flux Kontext

向 text_to_image 端点发送 POST 请求,将 model 设为 flux-kontext-pro,并附上描述所需图像的文字 prompt。如需上下文内编辑,可选填 image_url。

text_to_image
3

获取结果

端点返回任务 ID。轮询任务状态端点,直到状态变为 completed,然后从响应中获取生成的图像 URL。

task_id: tsk_abc123
参数

Flux Kontext API 参数

参数 类型 说明
model string 必填。flux-kontext-pro 或 flux-kontext-max。
prompt string 用于生成或编辑的文字指令。
image_url string 用于上下文内编辑的源图像 URL。
aspect_ratio string 可选。输出宽高比。

OpenClaw 上的 Flux Kontext 是什么?

Flux Kontext 由 Black Forest Labs 出品,是一个连续图像编辑模型,用户称其在精准修改方面优于 ChatGPT 和 Gemini。用文字描述需要改动的部分,它只修改那部分,其余保持不变——换装时人脸不变,换背景时产品位置不变。OpenClaw agent 通过 RunAPI 的 text_to_image 端点调用它。

Flux Kontext 使用场景

保留主体的背景替换

在保持被摄对象完全相同位置的同时替换产品或肖像背景——无需遮罩,无需修复,只需一条文字指令。

服装与外观修改

在保留角色面部特征的前提下更换服装、发色或配饰,适用于时尚效果图和角色设计迭代。

标牌与标签文字替换

替换现有图像中标牌、产品标签或店面上的文字——在提示词中输入新文字,Flux Kontext 即可原位渲染。

常见问题

Flux Kontext + OpenClaw 常见问题

OpenClaw 通用配置

还没配置?从 OpenClaw 的 RunAPI 配置指南开始。

OpenClaw 配置指南 →

Flux Kontext 模型目录

查看所有 Flux Kontext 变体、价格和 API 文档。

Flux Kontext 模型 →

立即在 OpenClaw 中试用 Flux Kontext。

获取免费 RunAPI key,将 prompt 粘贴到 OpenClaw,开始使用 Flux Kontext 生成图像。