Operations
Image generation - async submit (OpenAI Images compatible)
const url = 'https://coder.api.visioncoder.cn/v1/images/generations';const options = { method: 'POST', headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'}, body: '{"model":"gpt-image-2","prompt":"一只戴着宇航员头盔的橘猫,赛博朋克风格","n":1,"size":"1:1","resolution":"1k","image_urls":["example"]}'};
try { const response = await fetch(url, options); const data = await response.json(); console.log(data);} catch (error) { console.error(error);}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" ] }'Authorizations
Section titled “Authorizations”Request Bodyrequired
Section titled “Request Bodyrequired”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
Image model ID, e.g. gpt-image-2. Call GET /v1/models for the live list.
Example
gpt-image-2Text description of the image to generate. Chinese and English are both supported.
Example
一只戴着宇航员头盔的橘猫,赛博朋克风格Number of images to generate (1-10).
Aspect ratio such as 1:1, 16:9, auto; pixel sizes like 1024x1024 are also accepted.
Example
1:1Output resolution tier.
Reference images (URL or base64). Providing this switches to image-to-image mode; up to 14 images.
Responses
Section titled “Responses”Task submitted. Poll GET /v1/tasks/{task_id} with the returned id to fetch the result.
object
Status code; 200 means the task was submitted successfully.
object
Task ID, used to poll GET /v1/tasks/{task_id}.
Task status; submitted right after submission.
Example
{ "code": 200, "data": { "id": "task_01HZY3K8Q2W7X9V4", "status": "submitted" }}