YUYU_M4 Image to Image
YUYU_M4 edits an existing image according to a text instruction (prompt). Use aspect_ratio to choose the image size from 6 ratios, up to 1024×1024.
images is required and must contain exactly 1 image to edit; 0 or 2 or more images returns 422.
POST /api/tasks/image-generation
X-Api-Key: sk-live-xxxx
Content-Type: application/json
Idempotency-Key: optional, see below
Full example
images takes base64 data URIs; PNG, JPEG, and WebP are supported. The actual base64 content is omitted in this example:
curl -X POST https://yuyuvideo.com/api/tasks/image-generation \
-H "X-Api-Key: sk-live-xxxx" \
-H "Content-Type: application/json" \
-H "Idempotency-Key: order-20260716-00046" \
-d '{
"model": "YUYU_M4",
"prompt": "turn the background into a beach at sunset",
"images": ["data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAA..."],
"aspect_ratio": "1:1",
"payload": { "external_order_id": "order-20260716-00046" },
"callback_url": "https://example.com/webhooks/yuyu-image"
}'
On success, you get 201 Created and the task data. At this point the task is still queued and files is empty. credits is the number of credits charged for this task; the number in the example is for reference only:
{
"public_id": "01K1M2N3P4Q5R6S7T8V9W0XY16",
"type": 2,
"status": 0,
"credits": 10,
"params": {
"model": "YUYU_M4",
"prompt": "turn the background into a beach at sunset",
"images": ["data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAA..."],
"aspect_ratio": "1:1",
"payload": { "external_order_id": "order-20260716-00046" },
"callback_url": "https://example.com/webhooks/yuyu-image"
},
"error_code": null,
"error_message": null,
"created_at": "2026-07-16T08:00:00.000000Z",
"finished_at": null,
"files_expire_at": null,
"files_expired": false,
"files": []
}
To check progress and download the image, see Query Tasks and Download Results.
Parameters
| Field | Type | Required | Description |
|---|---|---|---|
model |
string | Yes | Set to YUYU_M4 |
prompt |
string | Yes | Edit instruction, up to 10000 characters |
images |
string[] | Yes | Exactly 1 image to edit; 0 or 2 or more images returns 422. Format: base64 data URI (data:image/{png|jpeg|webp};base64,...) |
aspect_ratio |
string | No | Image aspect ratio; actual size (width×height) in parentheses: 1:1 (1024×1024), 9:16 (576×1024, portrait), 16:9 (1024×576, landscape), 3:4 (768×1024), 4:3 (1024×768), 2:3 (688×1024). If omitted, the size is the model's default |
seed |
integer | No | Random seed; must be an integer of 0 or greater |
resolution |
— | No | Not supported; use aspect_ratio instead. Including it returns 422 |
payload |
object | No | Custom data, such as your order number. The system never reads or modifies it, and returns it as-is in task queries and webhook notifications |
callback_url |
string | No | URL to notify when the task finishes. Must start with https://, up to 2000 characters. See Callbacks (Webhook) |
Specifying a model that doesn't exist returns 422: Unknown model alias: {model}.
Including any parameter not listed in the table (except age_declared; see Pre-generation Age Check) returns 422; it is not ignored.
Idempotency-Key
Prevents duplicate tasks. Pass a custom string in this header; we recommend a unique value from your system, such as an order number:
Idempotency-Key: order-20260711-00046
If you send repeated requests with the same API key and the same Idempotency-Key within a short time, only one task is created and credits are charged only once. Subsequent duplicate requests return 200 OK with the original task.
Without this header, every request creates a new task.
Errors
| Status code | Cause | Response |
|---|---|---|
422 |
Invalid parameters, e.g. a missing required field, wrong type, images not containing exactly 1 image, or an aspect_ratio that isn't one of the allowed values |
The errors field lists the error for each field |
422 |
model doesn't exist |
{ "message": "Unknown model alias: {model}" } |
402 |
Insufficient credits | { "message": "Insufficient credits to complete this charge." } |
429 |
Too many queued image tasks | { "message": "Too many pending tasks of this type; please retry later." }. Use the Retry-After response header to decide when to retry |
For charging rules, see Credits and Billing.