在 Hermes Agent 中使用 Qwen 2 Image。
Qwen 2 Image 是阿里巴巴的图像生成和编辑模型。Hermes Agent 通过 RunAPI custom provider 端点调用它——发送 prompt,获取图像 URL。通过三种模型变体支持文生图、图像编辑和图像重混。
Use RunAPI to generate an image with Qwen 2 Image.
Requirements:
- Call the RunAPI text_to_image endpoint at https://runapi.ai/api/v1/task/text_to_image.
- Set the model to "qwen-2-text-to-image".
- Read the API key from the RUNAPI_API_KEY environment variable.
- Use the custom:runapi provider configured in Hermes Agent.
- The response returns a task_id. Poll the task status endpoint until the task completes, then retrieve the image URL from the output.
- For image editing, use model "qwen-2-edit-image" and include an image_url field.
- For remixing, use model "qwen-2-remix-image" and include an image_url field.
curl -X POST https://runapi.ai/api/v1/task/text_to_image \
-H "Authorization: Bearer $RUNAPI_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "qwen-2-text-to-image",
"prompt": "A traditional Chinese ink painting of misty mountains at dawn, elegant brushwork"
}'
{
"task_id": "tsk_abc123",
"status": "pending",
"model": "qwen-2-text-to-image"
}
三步在 Hermes Agent 中使用 Qwen 2 Image
配置 RunAPI
设置 RunAPI API key 为环境变量。如果你尚未在 Hermes Agent 中添加 RunAPI 作为 custom provider,请参考 Hermes Agent 配置指南,使用 base_url https://runapi.ai/v1 添加 custom:runapi。
export RUNAPI_API_KEY=runapi_xxx
调用 Qwen 2 Image
将 prompt 粘贴到 Hermes Agent,或直接调用 text_to_image 端点。将 model 字段设为 qwen-2-text-to-image(生成)、qwen-2-edit-image(编辑)或 qwen-2-remix-image(重混)。
text_to_image
获取结果
端点返回任务 ID。轮询任务状态端点,直到状态变为 completed,然后从输出中读取图像 URL。RunAPI SDK 会自动处理轮询。
task_id: tsk_abc123
Qwen 2 Image API 参数
| 参数 | 类型 | 说明 |
|---|---|---|
model |
string |
必填。qwen-2-text-to-image、qwen-2-edit-image 或 qwen-2-remix-image。 |
prompt |
string |
文字描述或编辑指令。 |
image_url |
string |
编辑或重混模式的源图像。 |
size |
string |
可选。输出尺寸。 |
Hermes Agent 上的 Qwen 2 Image 是什么?
Qwen 2 Image 是阿里巴巴的图像模型,通过单一 API 提供生成、编辑和混合创作三种模式。它能处理复杂的多对象场景,并原生理解中文、英文和混合语言提示词,特别适合多语言内容流水线。
Qwen 2 Image 使用场景
agent 工作流中的迭代图像编辑
在单次 Hermes Agent 运行中串联多个 Qwen 2 编辑步骤——先生成初始图像,再依次应用文字引导的修改,如替换背景、调整颜色或添加元素。
初创公司的低成本图像生成
将 Qwen 2 Image 作为高批量图像生成任务(产品效果图、社交媒体内容或开发阶段占位图)的经济实惠选择。
双语内容制作
无需翻译即可根据中英文提示词生成图像,在单一工作流中为双语营销活动或本地化产品页面产出视觉内容。
Qwen 2 Image + Hermes Agent 常见问题
可以。Hermes Agent 支持自定义 OpenAI 兼容 provider。将 RunAPI 添加为 custom:runapi,设置 base_url 为 https://runapi.ai/v1,key_env 为 RUNAPI_API_KEY,api_mode 为 chat_completions。然后以 qwen-2-text-to-image 为 model 调用 text_to_image 端点。
不需要。用于聊天模型的同一个 RUNAPI_API_KEY 也可以调用 Qwen 2 Image 和 RunAPI 目录中的所有其他模型。一个 key,一个余额,一个控制台。
异步。端点立即返回任务 ID。轮询任务状态端点或使用 webhook 回调了解图像是否已就绪。RunAPI SDK 和 CLI 会自动处理轮询。
Qwen 2 Image 按任务计费。查看 RunAPI 定价页面获取最新价格。没有月度订阅或最低消费——只为完成的生成付费。