创建/编辑 image
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 | 61442776 |
参数
{ "query": [], "path": [], "cookie": [], "header": [ { "id": "NQs7bxnpZf", "name": "Content-Type", "required": true, "enable": true, "description": "", "type": "string", "sampleValue": "application/json" }, { "id": "qb8tEQbCty", "name": "Accept", "required": true, "enable": true, "description": "", "type": "string", "sampleValue": "application/json" }, { "id": "gBxcCbXhsa", "name": "Authorization", "required": false, "enable": true, "description": "", "type": "string", "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": "生成图像的尺寸。对于 GPT 图像模型,必须是 1024x1024 、 1536x1024 (横版)、 1024x1536 (竖版)或 auto (默认值)之一,对于 dall-e-2 必须是 256x256 、 512x512 或 1024x1024 之一,对于 dall-e-3 必须是 1024x1024 、 1792x1024 或 1024x1792 之一。\n\n", "type": "string" } }, "required": [ "prompt", "n", "size" ], "x-apifox-orders": [ "prompt", "n", "size" ] }, "required": false, "mediaType": "", "examples": [ { "value": "{\n \"image\": \"https://lsky.zhongzhuan.chat/i/2024/10/17/6711068a14527.png\",\n \"size\": \"1024x1536\",\n \"prompt\": \"Change Z to X\",\n \"model\": \"grok-3-image\",\n \"n\": 2,\n }", "mediaType": "application/json" } ], "oasExtensions": "" }
响应
[ { "id": 562499897, "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": 562499897, "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": 440609003 } ]