> ## Documentation Index
> Fetch the complete documentation index at: https://docs.vizluma.online/llms.txt
> Use this file to discover all available pages before exploring further.

# GPT Image 2

> 使用 gpt-image-2 生成图片：请求参数、调用示例与结果处理。

## 接口与模型

| 项目 | 值 |
| - | - |
| 模型 ID | `gpt-image-2` |
| 接口 | `POST /v1/images/generations` |
| API Base URL | `https://api.vizluma.online/v1` |
| 调用形式 | 同步等待图片结果 |
| 计费方式 | 按张、按分辨率档位，见 [价格表](https://docs.vizluma.online/pricing.md) |

使用已有企业 API Key，无需注册。首次调用前请完成 [环境变量配置](https://docs.vizluma.online/getting-started/authentication.md)。

## 生成图片

```bash theme={null}
curl --fail-with-body --silent --show-error \
  --connect-timeout 15 --max-time 600 \
  "$VIZLUMA_BASE_URL/images/generations" \
  -H "Authorization: Bearer $VIZLUMA_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "gpt-image-2",
    "prompt": "生成一张白色陶瓷杯的商品插画，杯子居中，纯白背景，柔和阴影，无文字",
    "size": "1024x1024",
    "n": 1,
    "response_format": "url"
  }' \
  -o generation.json
```

读取 `generation.json` 中的 `data[].url` 获取图片。Python、Node.js 和保存脚本分别见 [客户端示例](https://docs.vizluma.online/guides/client-examples.md) 与 [图片结果](https://docs.vizluma.online/guides/image-results.md)。

## 参数

| 参数 | 类型 | 必填 | 说明 |
| - | - | - | - |
| `model` | string | 是 | 已开通权限的完整模型 ID，见 [模型列表](https://docs.vizluma.online/models/overview.md)。 |
| `prompt` | string | 是 | 非空的图像描述。建议说明主体、风格、构图、背景和文字要求。 |
| `size` | string | 否 | 建议显式使用 `1024x1024` 开始联调。其他尺寸见 [尺寸说明](https://docs.vizluma.online/guides/sizes-and-quality.md)。 |
| `n` | integer | 否 | 默认 `1`；网关接受 `1`～`10`，批量能力与企业调用限制需单独确认。按实际返回图片数量计费。 |
| `response_format` | string | 否 | `url` 或 `b64_json`。建议显式指定；本文的已实测基础示例使用 `url`。 |

`stream: true` 和 `mask` 不在当前支持范围内。不要假设官方接口的所有扩展参数在这里都可用。

## 已验证范围与注意事项

* 单张 `1024x1024`、URL 模式已完成真实调用和图片下载验证。
* 这是按张计费的接入方式，不需要按输入／输出 token 自行估算当前生图费用。
* 高分辨率及批量调用应先进行小规模联调，不要把价格档位视为能力验收结果。
* 编辑能力尚未完成本轮端到端验证，见 [图片编辑状态](https://docs.vizluma.online/api-reference/images-edits.md)。


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.