---
title: &quot;在爱马仕 (Hermes Agent) 中通过 RunAPI 使用 Imagen 4 — 图像 API 指南&quot;
url: &quot;https://runapi.ai/zh-CN/hermes-imagen-4.md&quot;
canonical: &quot;https://runapi.ai/zh-CN/hermes-imagen-4&quot;
locale: &quot;zh-CN&quot;
model: &quot;imagen-4&quot;
---

# 在 Hermes Agent 中使用 Imagen 4。

Imagen 4 是 Google DeepMind 的图像生成模型，具有精准的文字渲染和高 prompt 保真度。Hermes Agent 通过与聊天相同的 RunAPI custom provider 端点调用它，无需 ComfyUI 或 GPU 配置。

## API example

```bash
curl -X POST https://runapi.ai/v1/text_to_image \
  -H &quot;Authorization: Bearer $RUNAPI_API_KEY&quot; \
  -H &quot;Content-Type: application/json&quot; \
  -d &#39;{
    &quot;model&quot;: &quot;imagen-4&quot;,
    &quot;prompt&quot;: &quot;A ceramic coffee mug on a wooden table with morning light, the text HELLO printed on the side in serif font, photorealistic&quot;
  }&#39;

```

### Response

```json
{
  &quot;task_id&quot;: &quot;tsk_abc123&quot;,
  &quot;status&quot;: &quot;pending&quot;,
  &quot;model&quot;: &quot;imagen-4&quot;
}

```

## How it works

1. **配置 RunAPI** — 设置 RUNAPI_API_KEY 环境变量。如果你已经在 Hermes Agent 中将 RunAPI 配置为 custom:runapi provider 用于聊天，同一个 key 和 base_url 也适用于图像生成。
2. **调用 Imagen 4** — 向 text_to_image 端点发送 POST 请求，将 model 设为 imagen-4，并附上描述性 prompt。按需添加 aspect_ratio 或 negative_prompt。
3. **获取结果** — 响应包含一个 task_id。轮询任务状态端点，直到状态变为 completed。完成后的响应包含生成的图像 URL。

## Parameters

| Parameter | Type | Description |
|-----------|------|-------------|
| `model` | `string` | 必填。imagen-4、imagen-4-fast 或 imagen-4-ultra。 |
| `prompt` | `string` | 对所需图像的文字描述。 |
| `aspect_ratio` | `string` | 可选。例如 1:1、16:9、9:16。 |
| `negative_prompt` | `string` | 可选。生成图像中需要避免的内容。 |

## FAQ

### 可以在 Hermes Agent 中使用 Imagen 4 吗？

可以。Hermes Agent 通过 RunAPI text_to_image 端点调用 Imagen 4。将 model 字段设为 imagen-4，并使用为 custom:runapi provider 配置的同一个 RUNAPI_API_KEY 发送请求。无需 ComfyUI 或 GPU 租用。

### Imagen 4 需要单独的 API key 吗？

不需要。同一个 RUNAPI_API_KEY 适用于聊天、图像、视频和音乐的 113+ 个模型。一个 key，一个计费账户。

### Imagen 4 是异步还是同步的？

异步。初始请求返回状态为 pending 的 task_id。轮询任务状态端点直到任务完成，然后从响应中获取图像 URL。RunAPI SDK 会自动处理轮询。

### 通过 RunAPI 使用 Imagen 4 的价格是多少？

Imagen 4 按量计费，无月度最低消费。价格因档位而异：imagen-4-fast 最便宜，imagen-4 为标准档，imagen-4-ultra 质量最高。查看 RunAPI 定价页面获取最新每张价格。


## Links

- [Hermes Agent 配置指南 →](https://runapi.ai/zh-CN/hermes-agent)
- [Imagen 4 模型 →](https://runapi.ai/zh-CN/models/imagen-4)
- [Model catalog](https://runapi.ai/zh-CN/models)
- [API docs](https://runapi.ai/zh-CN/docs)
