---
url: https://limapi.com/docs/guide/images.md
---
# 图片生成 Images

```
POST /api/v1/images
POST /api/v1/images/generations
Authorization: Bearer sk-xxx
Content-Type: application/json
```

兼容 OpenAI 的图片生成接口。支持万象（Wan）系列和 Qwen 系列图片模型。

> 💡 两个路径完全等价，任选其一即可。图片生成为同步接口，`qwen-image-3.x-pro` 等模型单张生成可能耗时 1 分钟以上，请适当调大客户端超时（建议 ≥ 5 分钟）。

## Request

| 字段 | 类型 | 必填 | 说明 |
|------|------|------|------|
| model | string | \* | 模型 ID，如 `qwen-image-3.0-pro`、`qwen-image-3.0`、`wan2.7-image-pro`、`qwen-image-2.0` |
| prompt | string | \* | 图片描述文本 |
| n | integer | 可选 | 生成图片数量，默认 1 |
| size | string | 可选 | 图片尺寸，如 `1024x1024`、`1024x2048`、`2048x1024` |
| image\_urls | array | 可选 | 参考图片 URL 列表（图生图，推荐） |
| image\_url | string | 可选 | 单张参考图片 URL（图生图，兼容写法） |

> 💡 `image_urls` 和 `image_url` 二选一，同时传入时 `image_urls` 优先。

**常用图片模型：**

| 模型 | 说明 | 单价（元/张） |
|------|------|------|
| `qwen-image-3.0-pro` | Qwen Image 3.0 旗舰版，质量最高，生成耗时较长（可达 1 分钟以上） | 0.25 |
| `qwen-image-3.0` | Qwen Image 3.0 标准版 | 0.18 |
| `wan2.7-image-pro` | 万象 2.7 旗舰版，支持图生图/多图参考 | 0.50 |
| `wan2.7-image` | 万象 2.7 标准版 | 0.20 |
| `qwen-image-2.0-pro` | Qwen Image 2.0 旗舰版 | 0.50 |
| `qwen-image-2.0` | Qwen Image 2.0 标准版 | 0.20 |

> 💡 实际扣费可能因组织/租户折扣低于上表单价，以账单为准。完整模型列表可通过 `GET /api/v1/models` 查询。

**文生图示例：**

```json
{
  "model": "qwen-image-3.0-pro",
  "prompt": "一只可爱的猫咪坐在窗台上，阳光洒在它身上",
  "n": 1,
  "size": "1024x1024"
}
```

**文生图示例（万象系列）：**

```json
{
  "model": "wan2.7-image-pro",
  "prompt": "一只可爱的猫咪坐在窗台上，阳光洒在它身上",
  "n": 1,
  "size": "1024x1024"
}
```

**图生图示例（多张参考图）：**

```json
{
  "model": "wan2.7-image-pro",
  "prompt": "生成类似风格的图片",
  "image_urls": ["https://example.com/ref1.jpg", "https://example.com/ref2.jpg"],
  "n": 1,
  "size": "1024x1024"
}
```

**图生图示例（单张参考图）：**

```json
{
  "model": "wan2.7-image-pro",
  "prompt": "基于此图生成新图",
  "image_url": "https://example.com/ref.jpg",
  "n": 1,
  "size": "1024x1024"
}
```

## Response

```json
{
  "created": 1700000000,
  "data": [
    {
      "url": "https://dashscope-result.oss-cn-xxx.aliyuncs.com/xxx.png"
    }
  ]
}
```

> ⚠️ 返回的图片 URL 为上游 OSS 临时链接（通常 24 小时内有效），请及时下载保存。

## 代码示例

```bash
curl https://limapi.com/api/v1/images/generations \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer sk-xxx" \
  -d '{
    "model": "qwen-image-3.0-pro",
    "prompt": "一只可爱的猫咪坐在窗台上，阳光洒在它身上",
    "n": 1,
    "size": "1024x1024"
  }'
```

```python
from openai import OpenAI

client = OpenAI(
    base_url="https://limapi.com/api/v1",
    api_key="sk-xxx",
    timeout=300,  # 图片生成耗时较长，建议 5 分钟超时
)

result = client.images.generate(
    model="qwen-image-3.0-pro",
    prompt="一只可爱的猫咪坐在窗台上，阳光洒在它身上",
    size="1024x1024",
)

print(result.data[0].url)
```
