在 Hermes Agent 中使用 Imagen 4。
Imagen 4 是 Google DeepMind 的图像生成模型,具有精准的文字渲染和高 prompt 保真度。Hermes Agent 通过与聊天相同的 RunAPI custom provider 端点调用它,无需 ComfyUI 或 GPU 配置。
Use RunAPI to generate an image with Google Imagen 4 from Hermes Agent.
Requirements:
- Read the API key from RUNAPI_API_KEY. Do not hardcode the key.
- Use the custom:runapi provider already configured in Hermes Agent.
- Send a POST request to https://runapi.ai/v1/text_to_image.
- Set the model to imagen-4.
- Write a descriptive prompt for the image you want.
- The response returns a task_id. Poll the task status endpoint until the task completes.
- When the task is complete, retrieve the image URL from the response.
curl -X POST https://runapi.ai/v1/text_to_image \
-H "Authorization: Bearer $RUNAPI_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "imagen-4",
"prompt": "A ceramic coffee mug on a wooden table with morning light, the text HELLO printed on the side in serif font, photorealistic"
}'
{
"task_id": "tsk_abc123",
"status": "pending",
"model": "imagen-4"
}
三步在 Hermes Agent 中使用 Imagen 4
配置 RunAPI
设置 RUNAPI_API_KEY 环境变量。如果你已经在 Hermes Agent 中将 RunAPI 配置为 custom:runapi provider 用于聊天,同一个 key 和 base_url 也适用于图像生成。
export RUNAPI_API_KEY=runapi_xxx
调用 Imagen 4
向 text_to_image 端点发送 POST 请求,将 model 设为 imagen-4,并附上描述性 prompt。按需添加 aspect_ratio 或 negative_prompt。
POST /v1/text_to_image
获取结果
响应包含一个 task_id。轮询任务状态端点,直到状态变为 completed。完成后的响应包含生成的图像 URL。
task_id: tsk_abc123
Imagen 4 API 参数
| 参数 | 类型 | 说明 |
|---|---|---|
model |
string |
必填。imagen-4、imagen-4-fast 或 imagen-4-ultra。 |
prompt |
string |
对所需图像的文字描述。 |
aspect_ratio |
string |
可选。例如 1:1、16:9、9:16。 |
negative_prompt |
string |
可选。生成图像中需要避免的内容。 |
Hermes Agent 上的 Imagen 4 是什么?
Google DeepMind 的 Imagen 4 在横向对比中排名靠前,文字渲染更清晰,提示词遵从度优于多数竞品。其三档系统(Fast、Standard、Ultra)让你可以按图像选择成本与质量的权衡。Hermes Agent 通过 RunAPI custom provider 调用它——无需 Vertex AI 项目或 GCP 账户。
Imagen 4 使用场景
团队友好的图像生成
非技术团队成员可通过 Imagen 4 出色的提示词遵从性调整提示词并生成可用图像,无需提示词工程专业知识。
冒险与编辑风摄影
生成编辑质量的摄影作品——风景、美食、建筑、生活方式——光线、景深和自然色调调色精准。
成本优化的批量生成
在单一工作流中混合使用不同档位——起草阶段用 Fast(每张 $0.02),最终精选用 Ultra——在不牺牲最终输出质量的前提下控制批量成本。
Imagen 4 + Hermes Agent 常见问题
可以。Hermes Agent 通过 RunAPI text_to_image 端点调用 Imagen 4。将 model 字段设为 imagen-4,并使用为 custom:runapi provider 配置的同一个 RUNAPI_API_KEY 发送请求。无需 ComfyUI 或 GPU 租用。
不需要。同一个 RUNAPI_API_KEY 适用于聊天、图像、视频和音乐的 113+ 个模型。一个 key,一个计费账户。
异步。初始请求返回状态为 pending 的 task_id。轮询任务状态端点直到任务完成,然后从响应中获取图像 URL。RunAPI SDK 会自动处理轮询。
Imagen 4 按量计费,无月度最低消费。价格因档位而异:imagen-4-fast 最便宜,imagen-4 为标准档,imagen-4-ultra 质量最高。查看 RunAPI 定价页面获取最新每张价格。
立即在 Hermes Agent 中试用 Imagen 4。
获取免费 RunAPI key,配置 custom:runapi provider,开始使用 Google Imagen 4 生成图像。