# 图像生成 API

如何通过 /images/generations 生成和编辑图像：尺寸、格式、输入图像、响应，以及图像如何计费。

## 图像

图像模型使用 POST /images/generations，请求格式与 OpenAI 相同。size 可以是像素尺寸（"1024x1024"），也可以是模型提供的分辨率（"1K"、"1.5K"、"2K"、"3K"、"4K"；并非每个模型都全部支持），并可附带 aspect_ratio（"16:9"）。省略 size 则使用模型的标准尺寸。在支持的模型上，output_format 为 "jpeg"（默认）或 "png"。n 取 1 到 4。发送 image（URL 或 data URL，或其列表）可编辑图片或改变其风格。response_format 为 "b64_json" 时直接在响应中返回图片；为 "url" 时返回一个有效期一小时的链接。按生成的张数付费。部分模型对大图（超过该模型标注的像素数）另有更高的第二档价格，并对每张输入图像收费，有时前若干张免费；usage.input_images 显示计费的输入图像数量。各模型的尺寸、格式、输入图像上限和价格见下方「模型参考」以及 GET /models（pricing.image、pricing.image_large、pricing.image_input 和 image 对象）。

```
// response
{
  "id": "img_0123456789abcdef0123456789abcdef",
  "created": 1793984023,
  "model": "MODEL_NAME",
  "data": [{ "url": "https://api.apistore.cloud/v1/files/images/..." }],
  "usage": { "images": 1, "input_images": 1, "cost_usd": 0.04 }  // input_images: only when some were billed
}
```

---

Source: https://apistore.cloud/zh/docs/images
