创建 gpt-image-2
POST /v1/images/generations
说明
给定一个提示,该模型将返回一个或多个预测的完成,并且还可以返回每个位置的替代标记的概率。
为提供的提示和参数创建完成
官方文档:https://platform.openai.com/docs/api-reference/images/create
概览
| Method | POST |
|---|---|
| Path | /v1/images/generations |
| Type | http |
| Status | 1 |
| Module | 2102810 |
| Folder | 84826875 |
参数
{ "query": [], "path": [], "cookie": [], "header": [ { "id": "NQs7bxnpZf", "name": "Content-Type", "required": true, "description": "", "type": "string", "enable": true, "sampleValue": "application/json" }, { "id": "qb8tEQbCty", "name": "Accept", "required": true, "description": "", "type": "string", "enable": true, "sampleValue": "application/json" }, { "required": false, "description": "", "type": "string", "id": "gBxcCbXhsa", "enable": true, "name": "Authorization", "sampleValue": "Bearer {{YOUR_API_KEY}}" } ] }
请求体
{ "type": "application/json", "parameters": [], "jsonSchema": { "type": "object", "properties": { "prompt": { "description": "所需图像的文本描述。最大长度为 1000 个字符。", "type": "string" }, "n": { "description": "要生成的图像数。必须介于 1 和 10 之间。", "type": "integer" }, "size": { "description": "图片尺寸\n1024x1024 正方形\n1536x1024 横版\n1024x1536 竖版\n2048x2048 2K正方形\n2048x1152 2K横版\n3840x2160 4K横版\n2160x3840 4K竖版\nauto 默认\n\n尺寸严格限制规则\n1. 图片最大边长 ≤ 3840px\n2. 宽高两边像素均为 16px 的倍数\n3. 长边 / 短边 比值 ≤ 3:1\n4. 总像素范围:最小 655360 ~ 最大 8294400", "type": "string" }, "format": { "type": "string", "description": "图片格式\n可选:png 、 jpeg 、 webp" }, "quality": { "type": "string", "description": "图片画质\n可选:low 、 medium 、 high 、 auto(默认)" }, "model": { "type": "string", "description": "模型名" } }, "required": [ "prompt", "model", "n" ], "x-apifox-orders": [ "model", "prompt", "size", "format", "quality", "n" ] }, "required": false, "mediaType": "", "examples": [ { "value": "{\n \"model\": \"gpt-image-2\",\n \"prompt\": \"A childrens book drawing of a veterinarian using a stethoscope to listen to the heartbeat of a baby otter.\",\n \"n\": 1,\n \"size\": \"1024x1024\",\n \"quality\": \"low\",\n \"format\": \"jpeg\"\n}", "mediaType": "application/json" } ], "oasExtensions": "" }
响应
[ { "id": 666443878, "name": "OK", "code": 200, "contentType": "json", "jsonSchema": { "type": "object", "properties": { "id": { "type": "string" }, "object": { "type": "string" }, "created": { "type": "integer" }, "choices": { "type": "array", "items": { "type": "object", "properties": { "index": { "type": "integer" }, "message": { "type": "object", "properties": { "role": { "type": "string" }, "content": { "type": "string" } }, "required": [ "role", "content" ], "x-apifox-orders": [ "role", "content" ] }, "finish_reason": { "type": "string" } }, "x-apifox-orders": [ "index", "message", "finish_reason" ] } }, "usage": { "type": "object", "properties": { "prompt_tokens": { "type": "integer" }, "completion_tokens": { "type": "integer" }, "total_tokens": { "type": "integer" } }, "required": [ "prompt_tokens", "completion_tokens", "total_tokens" ], "x-apifox-orders": [ "prompt_tokens", "completion_tokens", "total_tokens" ] } }, "required": [ "id", "object", "created", "choices", "usage" ], "x-apifox-orders": [ "id", "object", "created", "choices", "usage" ] }, "itemSchema": {}, "description": "", "mediaType": "", "headers": [], "oasExtensions": "" } ]
响应示例
[ { "name": "OK", "responseId": 666443878, "data": "{\n \"id\": \"chatcmpl-123\",\n \"object\": \"chat.completion\",\n \"created\": 1677652288,\n \"choices\": [\n {\n \"index\": 0,\n \"message\": {\n \"role\": \"assistant\",\n \"content\": \"\\n\\nHello there, how may I assist you today?\"\n },\n \"finish_reason\": \"stop\"\n }\n ],\n \"usage\": {\n \"prompt_tokens\": 9,\n \"completion_tokens\": 12,\n \"total_tokens\": 21\n }\n}", "description": "", "oasKey": "", "oasExtensions": "", "id": 587196258 } ]