在 Hermes Agent 中使用 Flux Kontext。
Flux Kontext 由 Black Forest Labs 出品,支持文字引导的图像编辑和生成,并保持角色一致性。Hermes Agent 通过 RunAPI 的 custom:runapi provider 调用它,与聊天使用相同的 key 和 base URL。
Use RunAPI to generate an image with Flux Kontext Pro through Hermes Agent.
Requirements:
- Use the custom:runapi provider already configured in Hermes Agent
- Call the RunAPI text_to_image endpoint at https://runapi.ai/v1/text_to_image
- Set model to "flux-kontext-pro"
- The RUNAPI_API_KEY environment variable provides 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"
}
三步在 Hermes Agent 中使用 Flux Kontext
配置 RunAPI
设置 RUNAPI_API_KEY 环境变量。如果你已经在 Hermes Agent 中将 RunAPI 配置为 custom:runapi provider 用于聊天,同一个 key 和 base_url 也适用于图像生成,无需额外配置。
export RUNAPI_API_KEY=runapi_xxx
调用 Flux Kontext
向 text_to_image 端点发送 POST 请求,将 model 设为 flux-kontext-pro,并附上描述所需图像的文字 prompt。如需上下文内编辑,可选填 image_url。
text_to_image
获取结果
端点返回一个任务 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 |
可选。输出宽高比。 |
Hermes Agent 上的 Flux Kontext 是什么?
Flux Kontext 是 Black Forest Labs 基于 120 亿参数整流流变换器构建的指令式图像编辑器,支持多轮编辑——可以依序进行多次修改,模型在每一步都保留上一步的上下文。Hermes Agent 通过 RunAPI 自定义 provider 端点调用它,便于构建多步骤编辑流水线。
Flux Kontext 使用场景
多轮编辑工作流
依次链接多个编辑步骤——生成图像、调整光线、替换背景、添加文字——每一步在上一步结果的基础上继续。
风格转换流水线
在保留被摄对象构图的前提下将照片转换为油画、素描或动漫风格,用于同一内容的风格变体创作。
天气与光线调整
无需从头重新生成整个场景,即可修改现有照片中的时间、天气或光线设置。
Flux Kontext + Hermes Agent 常见问题
可以。在 Hermes Agent 中将 RunAPI 配置为 custom:runapi provider,然后以 flux-kontext-pro 为 model 调用 text_to_image 端点。用于聊天的同一个 RUNAPI_API_KEY 也可以处理图像生成。
不需要。同一个 RUNAPI_API_KEY 适用于所有 RunAPI 模型——LLM、图像、视频和音乐。一个 key,一个计费账户。
异步。API 立即返回任务 ID。轮询任务状态端点或使用 webhook 回调接收已完成的图像 URL。
Flux Kontext Pro 起价每张 2.5 美分。Flux Kontext Max 精度更高,价格也更高。查看 RunAPI 定价页面获取最新价格——按量计费,无需订阅。
立即在 Hermes Agent 中试用 Flux Kontext。
获取免费 RunAPI key,配置 custom:runapi provider,开始使用 Flux Kontext 生成图像。