跳转到内容
控制台

Operations

Image generation - async submit (OpenAI Images compatible)

POST
/v1/images/generations
curl --request POST \
--url https://coder.api.visioncoder.cn/v1/images/generations \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '{ "model": "gpt-image-2", "prompt": "一只戴着宇航员头盔的橘猫,赛博朋克风格", "n": 1, "size": "1:1", "resolution": "1k", "image_urls": [ "example" ] }'
Media typeapplication/json
CreateImagesGenerationReq

OpenAI Images-compatible generation request. The task runs asynchronously: this endpoint returns a task ID, and the result is fetched via GET /v1/tasks/{task_id}.

object
model
required

Image model ID, e.g. gpt-image-2. Call GET /v1/models for the live list.

string
Example
gpt-image-2
prompt
required

Text description of the image to generate. Chinese and English are both supported.

string
Example
一只戴着宇航员头盔的橘猫,赛博朋克风格
n

Number of images to generate (1-10).

integer
default: 1 >= 1 <= 10
size

Aspect ratio such as 1:1, 16:9, auto; pixel sizes like 1024x1024 are also accepted.

string
Example
1:1
resolution

Output resolution tier.

string
default: 1k
Allowed values: 1k 2k 4k
image_urls

Reference images (URL or base64). Providing this switches to image-to-image mode; up to 14 images.

Array<string>
<= 14 items

Task submitted. Poll GET /v1/tasks/{task_id} with the returned id to fetch the result.

Media typeapplication/json
CreateImagesGenerationResp
object
code
required

Status code; 200 means the task was submitted successfully.

integer
data
required
ImagesTaskData
object
id
required

Task ID, used to poll GET /v1/tasks/{task_id}.

string
status
required

Task status; submitted right after submission.

string
Example
{
"code": 200,
"data": {
"id": "task_01HZY3K8Q2W7X9V4",
"status": "submitted"
}
}