在 Hermes Agent 中使用 Z Image。
Z Image 是阿里巴巴的快速图像生成模型,支持中英文双语文字渲染。Hermes Agent 通过 RunAPI custom provider 端点调用它——与聊天使用相同的 base_url 和 API key,无需额外插件或 GPU 租用。
Use the RunAPI text_to_image endpoint to generate an image with Z Image.
Requirements:
- Use the RUNAPI_API_KEY environment variable for authentication.
- Send a POST request to https://runapi.ai/v1/text_to_image.
- Set model to "z-image".
- Write a descriptive prompt for the image you want to generate.
- The response returns a task_id. Poll the task status endpoint until the task completes, then retrieve the image URL from the output.
- Use the custom:runapi provider configured in your Hermes Agent config.yaml.
curl -X POST https://runapi.ai/v1/text_to_image \
-H "Authorization: Bearer $RUNAPI_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "z-image",
"prompt": "A neon-lit Tokyo street at night with Japanese shop signs, cinematic lighting, 8K detail"
}'
{
"task_id": "tsk_abc123",
"status": "pending",
"model": "z-image"
}
三步在 Hermes Agent 中使用 Z Image
配置 RunAPI
将 RunAPI API key 设置为环境变量。如果你已经在 Hermes Agent 中将 RunAPI 配置为 custom provider,同一个 key 和 base_url 也适用于图像生成。
export RUNAPI_API_KEY=runapi_xxx
调用 Z Image
向 text_to_image 端点发送 POST 请求,将 model 设为 z-image,并附上文字 prompt。Z Image 支持中英文双语 prompt,并能精准渲染文字。
text_to_image
获取结果
API 立即返回 task_id。轮询任务状态端点,直到状态变为 completed,然后从响应输出中获取生成的图像 URL。
task_id: tsk_abc123
Z Image API 参数
| 参数 | 类型 | 说明 |
|---|---|---|
model |
string |
必填。使用 z-image。 |
prompt |
string |
文字描述,支持中文和英文。 |
negative_prompt |
string |
可选。图像中需要避免的内容。 |
size |
string |
可选。输出尺寸,例如 1024x1024。 |
Hermes Agent 上的 Z Image 是什么?
Z Image 亚秒级生成写实图像,提示词遵从度高,面部细节精准。基于 Apache 2.0 开源权重,通过 RunAPI 每张约 $0.004,是最快也是最便宜的图像模型。Hermes Agent 通过与聊天相同的 custom provider 调用它。
Z Image 使用场景
影视动画分镜制作
以亚秒级速度生成分镜帧,快速迭代构图和摄像机角度,速度足以跟上实时创意讨论的节奏。
电商产品可视化
以 RunAPI 上最低的单张成本生成具有写实材质和光线效果的产品列表图,适合大批量目录生成。
教育插图
创作带中英双语文字标注的教育示意图和插图,适用于面向中英文受众的教科书、课程材料和培训内容。
Z Image + Hermes Agent 常见问题
可以。如果你在 Hermes Agent 中配置了 RunAPI 作为 custom provider,同一个 API key 和 base_url 也可以处理 Z Image 请求。向 text_to_image 端点发送 POST 请求,将 model 设为 z-image。
不需要。用于聊天和其他模型的同一个 RUNAPI_API_KEY 也适用于 Z Image。所有 RunAPI 模型共享一个 key 和一个点数余额。
异步。API 立即返回 task_id。轮询任务状态端点或使用 webhook 回调了解图像是否已就绪。RunAPI SDK 会自动处理轮询。
Z Image 按任务按量计费。查看 RunAPI 定价页面获取最新价格。没有月度订阅或最低消费。