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

# 在 Hermes Agent 中使用 Qwen 2 Image。

Qwen 2 Image 是阿里巴巴的图像生成和编辑模型。Hermes Agent 通过 RunAPI custom provider 端点调用它——发送 prompt，获取图像 URL。通过三种模型变体支持文生图、图像编辑和图像重混。

## API example

```bash
curl -X POST https://runapi.ai/api/v1/task/text_to_image \
  -H &quot;Authorization: Bearer $RUNAPI_API_KEY&quot; \
  -H &quot;Content-Type: application/json&quot; \
  -d &#39;{
    &quot;model&quot;: &quot;qwen-2-text-to-image&quot;,
    &quot;prompt&quot;: &quot;A traditional Chinese ink painting of misty mountains at dawn, elegant brushwork&quot;
  }&#39;

```

### Response

```json
{
  &quot;task_id&quot;: &quot;tsk_abc123&quot;,
  &quot;status&quot;: &quot;pending&quot;,
  &quot;model&quot;: &quot;qwen-2-text-to-image&quot;
}

```

## How it works

1. **配置 RunAPI** — 设置 RunAPI API key 为环境变量。如果你尚未在 Hermes Agent 中添加 RunAPI 作为 custom provider，请参考 Hermes Agent 配置指南，使用 base_url https://runapi.ai/v1 添加 custom:runapi。
2. **调用 Qwen 2 Image** — 将 prompt 粘贴到 Hermes Agent，或直接调用 text_to_image 端点。将 model 字段设为 qwen-2-text-to-image（生成）、qwen-2-edit-image（编辑）或 qwen-2-remix-image（重混）。
3. **获取结果** — 端点返回任务 ID。轮询任务状态端点，直到状态变为 completed，然后从输出中读取图像 URL。RunAPI SDK 会自动处理轮询。

## Parameters

| Parameter | Type | Description |
|-----------|------|-------------|
| `model` | `string` | 必填。qwen-2-text-to-image、qwen-2-edit-image 或 qwen-2-remix-image。 |
| `prompt` | `string` | 文字描述或编辑指令。 |
| `image_url` | `string` | 编辑或重混模式的源图像。 |
| `size` | `string` | 可选。输出尺寸。 |

## FAQ

### 可以在 Hermes Agent 中使用 Qwen 2 Image 吗？

可以。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 端点。

### Qwen 2 Image 需要单独的 API key 吗？

不需要。用于聊天模型的同一个 RUNAPI_API_KEY 也可以调用 Qwen 2 Image 和 RunAPI 目录中的所有其他模型。一个 key，一个余额，一个控制台。

### Qwen 2 Image 是异步还是同步的？

异步。端点立即返回任务 ID。轮询任务状态端点或使用 webhook 回调了解图像是否已就绪。RunAPI SDK 和 CLI 会自动处理轮询。

### 在 RunAPI 上使用 Qwen 2 Image 的价格是多少？

Qwen 2 Image 按任务计费。查看 RunAPI 定价页面获取最新价格。没有月度订阅或最低消费——只为完成的生成付费。


## Links

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