POST
https://nezhagate.com/v1/images/generations
OpenAI 兼容的图片生成接口。文生图只需 prompt;图生图额外传入 image 参考图 URL,模型在其基础上生成。
在 Playground 试用 →认证
Authorization: Bearer YOUR_API_KEY Content-Type: application/json
在控制台创建 API Key 后即可调用。
请求参数
| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
| model | string | 是 | 模型 ID,固定为 gpt-image-2。 |
| prompt | string | 是 | 图片描述提示词。 |
| size | string | 否 | 尺寸:1024x1024 / 1024x1536 / 1536x1024。 |
| n | integer | 否 | 生成数量,默认 1。 |
| image | string | 否 | 图生图模式:参考图 URL。提供后在其基础上生成。 |
请求示例
curl https://nezhagate.com/v1/images/generations \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "gpt-image-2",
"prompt": "a serene ink-wash poster, lots of negative space",
"size": "1024x1024",
"n": 1
}'响应示例
{
"created": 1710000000,
"model": "gpt-image-2",
"data": [{"url": "https://.../image.png"}]
}错误码
| Code | 说明 |
|---|---|
| 401 | Invalid or missing API key |
| 402 | Insufficient balance / key limit reached |
| 400 | Invalid parameters or model |
| 429 | Rate limited |
| 502 | All upstream providers failed |