# 图片生成与编辑

使用文字或参考图片创建图像，以 URL 或 Base64 获取结果。

## 构建请求

### GPT Image 2

- quality: low / auto → 1K; medium → 2K; high → 4K
- n: 1
- size: WIDTHxHEIGHT；宽高为 8 的倍数，且满足对应档位像素上限。
- image[]: 编辑接口上传 1–4 张图片。

POST /v1/images/generations

```json
{
  "model": "gpt-image-2",
  "prompt": "A ceramic teapot on a sunlit table",
  "aspect_ratio": "1:1",
  "quality": "medium",
  "n": 1,
  "response_format": "url"
}
```

### GPT Image 2.5 SFW

- quality: low / auto → 1K
- n: 1
- size: 宽高为 16 的倍数；总像素 655360–1048576，宽高比不超过 3:1，单边不超过 3840。
- image[]: 编辑接口上传 1–4 张图片。

POST /v1/images/generations

```json
{
  "model": "gpt-image-2.5-sunburst",
  "prompt": "A ceramic teapot on a sunlit table",
  "aspect_ratio": "1:1",
  "quality": "low",
  "n": 1,
  "response_format": "url"
}
```

### Seedream 5.0 Pro

- quality: low / auto → 1K; medium → 2K
- aspect_ratio: 1:1 / 16:9 / 9:16 / 4:3 / 3:4
- n: 1
- image_urls / image[]: 1–10 张；smart 比例仅限提供参考图时使用。

POST /v1/images/generations

```json
{
  "model": "seedream-5.0-pro",
  "prompt": "A ceramic teapot on a sunlit table",
  "aspect_ratio": "1:1",
  "quality": "low",
  "n": 1,
  "response_format": "url"
}
```

### Qwen Edit 2511

- mode: reference
- image_urls / image[]: 必填，1–2 张图片。
- resolution: 固定 720p，不使用 quality 切换。
- n: 1

POST /v1/images/generations

```json
{
  "model": "qwen-edit-2511",
  "prompt": "Change the background to a quiet garden",
  "mode": "reference",
  "aspect_ratio": "1:1",
  "image_urls": [
    "https://example.com/reference.png"
  ],
  "n": 1,
  "response_format": "url"
}
```

### NovelAI V4.5

- n: 1–4
- aspect_ratio: 按比例映射为服务端预设尺寸。
- image[]: 编辑时只接受 1 张图片。
- quality: 不适用；精细参数见 NovelAI 文档。

POST /v1/images/generations

```json
{
  "model": "nai-v4.5",
  "prompt": "watercolor, a quiet garden",
  "aspect_ratio": "1:1",
  "n": 1,
  "response_format": "url"
}
```

### NovelAI V5

- model: nai-diffusion-5-full
- action: generate / img2img / infill
- parameters.steps: 1–50
- parameters.n_samples: 1–4
- parameters.v4_prompt.caption.char_captions: 最多 32 个，推荐自动位置。

POST /ai/generate-image

```json
{
  "model": "nai-diffusion-5-full",
  "input": "watercolor, a quiet garden",
  "action": "generate",
  "parameters": {
    "width": 1024,
    "height": 1024,
    "steps": 23,
    "n_samples": 1,
    "scale": 5,
    "seed": 42,
    "negative_prompt": ""
  }
}
```

### Nano Banana 2

- 接口: 仅网页工作台，暂未开放公共 API。
- resolution: 1K / 2K / 4K
- aspect_ratio: smart / 1:1 / 3:2 / 2:3 / 4:3 / 3:4 / 5:4 / 4:5 / 16:9 / 9:16 / 21:9
- 参考图: 最多 14 张账号内图片。
- 生成数量: 1



## 通用参数

| 字段 | 说明 |
| --- | --- |
| model | 必填，使用当前 Key 可用的模型 ID。 |
| prompt | 必填，描述目标画面。 |
| n | 生成数量，首次接入建议使用 1。 |
| size / quality | 尺寸和质量取值随模型变化，不能跨模型照搬。 |
| response_format | url \| b64_json |
| image_urls | 部分模型支持的公网参考图 URL 数组。 |

## 上传参考图编辑

```bash
curl --fail-with-body https://noveadream.com/v1/images/edits \
  -H "Authorization: Bearer $NOVEA_API_KEY" \
  -H "Idempotency-Key: $REQUEST_ID" \
  -F "model=gpt-image-2" \
  -F "prompt=Change the background to a quiet garden" \
  -F "image[]=@reference.png"
```

multipart 上传让客户端设置 Content-Type 边界，不要手动指定 application/json。多个文件可重复使用 image[]。

## 读取结果

```json
{
  "created": 1791300000,
  "data": [{ "url": "https://example.com/result.png" }]
}
```

选择 b64_json 时读取 data[].b64_json。结果链接应及时下载保存，不要作为永久存储地址。
