典名词元DMTOKENSHome
API DocumentationThird-Party Tools Tutorial
AI Model APIImageZ-Image

Synchronous Image Generation Call

POST/api/v1/image/generation

Header Parameters

Authorization?string

Use Bearer Token authentication. Format: Authorization: Bearer sk-xxxxxx

Request Body

application/json

model*string

Model name. Must be: z-image-turbo.

Value in"z-image-turbo"
input*object

Basic input information.

messages*array<object>

Request content array. Currently, only single-turn conversations are supported, i.e., passing a single set of role and content parameters; multi-turn conversations are not supported.

[]?object
role*string

The role of the message. This parameter must be set to user.

content*array<object>

Message content array. Must contain exactly one text object.

[]?object
text*string

Positive prompts are used to describe the desired content, style, and composition of the generated image. Both Chinese and English are supported, with a maximum length of 800 characters; each Chinese character, letter, number, or symbol counts as one character, and any excess will be automatically truncated. Example value: A sitting orange cat with a cheerful expression, lively and cute, realistic and accurate. Note: Only one text parameter is supported; passing none or multiple will result in an error.

parameters?object

Image processing parameters.

size?string

Resolution of the output image, in the format of widthheight. Default value: 10241536. Total pixel limit: total pixels must be within [512512, 20482048]. Recommended resolution range: total pixels within [10241024, 15361536] for better image quality. Example value: 10241536. Recommended resolutions for 10241024 total pixels: 1:1: 10241024 2:3: 8321248 3:2: 1248832 3:4: 8641152 4:3: 1152864 7:9: 8961152 9:7: 1152896 9:16: 7201280 9:21: 5761344 16:9: 1280720 21:9: 1344576 Recommended resolutions for 12801280 total pixels: 1:1: 12801280 2:3: 10241536 3:2: 15361024 3:4: 11041472 4:3: 14721104 7:9: 11201440 9:7: 14401120 9:16: 8641536 9:21: 7201680 16:9: 1536864 21:9: 1680720 Recommended resolutions for 15361536 total pixels: 1:1: 15361536 2:3: 12481872 3:2: 18721248 3:4: 12961728 4:3: 17281296 7:9: 13441728 9:7: 17281344 9:16: 11522048 9:21: 8642016 16:9: 20481152 21:9: 2016*864

prompt_extend?boolean

Whether to enable intelligent prompt (text) rewriting. When enabled, a large model will be used to optimize the prompt and output the thinking process. false: Default value, disables intelligent rewriting. Outputs the image and the original text prompt. true: Enables intelligent rewriting. Outputs the image, the optimized text prompt, and the thinking process.

seed?integer

Random seed, value range [0, 2147483647]. Using the same seed parameter value keeps the generated content relatively stable. If not provided, the algorithm will automatically use a random seed. Note: The model generation process is probabilistic, so even with the same seed, identical results cannot be guaranteed for each generation.

Response Body

application/json

Success

TypeScript Definitions

Use the response body type in TypeScript.

code*integer

Status Code

data*object

Data Object

urls*array<string>

Result Set

[]?string
usage*object

Usage Information

images*integer

Number of Images

seconds*integer

Video Seconds

input_tokens*integer

Input Token Count

total_tokens*integer

Total Tokens

output_tokens*integer

Output token count

expired*string

Validity Period

task_id*string

Task ID

task_status*string

Task Status

message*string

Status Information

request_id*string

Request ID

curl -X POST "https://api.ygw.ai/api/v1/image/generation" \  -H "Content-Type: application/json" \  -d '{    "model": "z-image-turbo",    "input": {      "messages": [        {          "role": "string",          "content": [            {              "text": "string"            }          ]        }      ]    }  }'
{
  "code": 0,
  "data": {
    "urls": [
      "string"
    ],
    "usage": {
      "images": 0,
      "seconds": 0,
      "input_tokens": 0,
      "total_tokens": 0,
      "output_tokens": 0
    },
    "expired": "string",
    "task_id": "string",
    "task_status": "string"
  },
  "message": "string",
  "request_id": "string"
}