在 OpenClaw 中使用 Imagen 4。
Imagen 4 是 Google DeepMind 的图像生成模型,具有精准的文字渲染和高 prompt 保真度。OpenClaw agent 通过与聊天相同的 RunAPI 端点和 API key 调用它,无需安装额外技能。
Use RunAPI to generate an image with Google Imagen 4.
Requirements:
- Read the API key from RUNAPI_API_KEY. Do not hardcode the key.
- 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"
}
三步在 OpenClaw 中使用 Imagen 4
配置 RunAPI
设置 RUNAPI_API_KEY 环境变量。如果你已经在 OpenClaw 中将 RunAPI 配置为 provider 用于聊天,同一个 key 也适用于图像生成。
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 |
可选。生成图像中需要避免的内容。 |
OpenClaw 上的 Imagen 4 是什么?
Imagen 4 是 Google DeepMind 的图像模型,提供三档——Fast 用于快速原型、Standard 用于生产环境、Ultra 用于最高细节——最便宜的档位每张约 $0.02。OpenClaw agent 通过同一个 RunAPI key 调用所有三档。
Imagen 4 使用场景
大规模快速原型
使用 Fast 档以每张 $0.02 进行快速概念探索,在确定方向后再切换至 Standard 或 Ultra 档,生成若干变体。
含可读文字的 UI 与标签设计
生成界面效果图、产品标签和标牌设计,其中嵌入的文字可清晰渲染并严格遵循提示词。
写实纹理与材质
创作写实材质纹理、复古旅行明信片和充满冒险感的摄影场景,光线和表面细节精准。
Imagen 4 + OpenClaw 常见问题
可以。OpenClaw agent 通过 RunAPI text_to_image 端点调用 Imagen 4。将 model 字段设为 imagen-4,并使用聊天所用的同一个 RUNAPI_API_KEY 发送请求。无需额外技能或插件。
不需要。同一个 RUNAPI_API_KEY 适用于聊天、图像、视频和音乐的 113+ 个模型。一个 key,一个计费账户。
异步。初始请求返回状态为 pending 的 task_id。轮询任务状态端点直到任务完成,然后从响应中获取图像 URL。RunAPI SDK 会自动处理轮询。
Imagen 4 按量计费,无月度最低消费。价格因档位而异:imagen-4-fast 最便宜,imagen-4 为标准档,imagen-4-ultra 质量最高。查看 RunAPI 定价页面获取最新每张价格。