---
title: &quot;在龙虾 (OpenClaw) 中通过 RunAPI 使用 Grok Imagine — 图像与视频 API 指南&quot;
url: &quot;https://runapi.ai/zh-CN/openclaw-grok-imagine.md&quot;
canonical: &quot;https://runapi.ai/zh-CN/openclaw-grok-imagine&quot;
locale: &quot;zh-CN&quot;
model: &quot;grok-imagine&quot;
---

# 在 OpenClaw 中使用 Grok Imagine。

Grok Imagine 是 xAI 的图像和视频生成套件——文生图、图生图、文生视频和图生视频。OpenClaw agent 通过与聊天相同的 RunAPI key 和 /v1 端点调用它，无需安装额外技能。

## 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;grok-imagine-text-to-image&quot;,
    &quot;prompt&quot;: &quot;a robot hand placing a chess piece on a board, dramatic side lighting, slow motion feel&quot;
  }&#39;

```

### Response

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

```

## How it works

1. **配置 RunAPI** — 在 shell profile 中设置 RUNAPI_API_KEY 环境变量。如果 RunAPI 已在 OpenClaw 中配置用于聊天，同一个 key 也适用于 Grok Imagine，无需额外配置。
2. **调用 Grok Imagine** — 向 text_to_image 端点发送 POST 请求，将 model 设为 grok-imagine-text-to-image，并附上描述图像的 prompt。视频生成请使用 text_to_video 和 grok-imagine-text-to-video。
3. **获取结果** — API 立即返回 task_id。轮询任务状态端点，直到状态变为 completed，然后从响应中获取输出图像或视频 URL。

## Parameters

| Parameter | Type | Description |
|-----------|------|-------------|
| `model` | `string` | 必填。例如 grok-imagine-text-to-image、grok-imagine-image-to-video。 |
| `prompt` | `string` | 对所需输出的文字描述。 |
| `image_url` | `string` | 图生图或图生视频的源图像 URL。 |
| `aspect_ratio` | `string` | 可选。输出宽高比，例如 16:9、1:1。 |

## FAQ

### 可以在 OpenClaw 中使用 Grok Imagine 吗？

可以。如果 RunAPI 已在 OpenClaw 中配置为 OpenAI 兼容 provider，同一个 API key 和 /v1 端点也适用于 Grok Imagine。将 model 设为 grok-imagine-text-to-image 并调用 text_to_image 端点。

### Grok Imagine 需要单独的 API key 吗？

不需要。用于聊天和其他模型的同一个 RUNAPI_API_KEY 也适用于 Grok Imagine。一个 key 覆盖 RunAPI 目录中 113+ 个模型。

### Grok Imagine 是异步还是同步的？

异步。API 立即返回 task_id。轮询任务状态端点直到任务完成。RunAPI SDK 和 CLI 会自动处理轮询。

### Grok Imagine 的价格是多少？

Grok Imagine 通过 RunAPI 按任务计费。查看 RunAPI 定价页面获取最新价格。生成失败不收费。


## Links

- [OpenClaw 配置指南 →](https://runapi.ai/zh-CN/openclaw)
- [Grok Imagine 模型 →](https://runapi.ai/zh-CN/models/grok-imagine)
- [Model catalog](https://runapi.ai/zh-CN/models)
- [API docs](https://runapi.ai/zh-CN/docs)
