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

Image Generation

POST/api/v1/image/generation

Header Parameters

Authorization*string

Format: Authorization: Bearer sk-xxxxxx

Region*string

Fixed value: Region is cn-north-1

Service*string

Fixed value: Service is cv

Request Body

application/json

model*string

Model name, fixed value: jimeng_t2i_v40

Value in"jimeng_t2i_v40"
req_key*string

Service representation, fixed value: jimeng_t2i_v40

Value in"jimeng_t2i_v40"
image_urls?array<string>

Image file URLs, supporting the input of 0 to 10 images. The more images and the larger the image sizes, the longer the overall service processing time. It is recommended to limit the input to 6 images or fewer, as too many images will degrade the reference effect.

[]?string
prompt*string

Prompts for image generation support both Chinese and English input. Recommendations: The maximum length should not exceed 800 characters, as overly long prompts may result in abnormal image generation or failure to take effect. It supports directly specifying the image aspect ratio in the prompt, and the model will intelligently determine the aspect ratio based on the "size" field, generating 2K resolution images with an aspect ratio not exceeding 3 by default. It is not recommended to input special symbols such as $ other than "".

size?integer

Area of the generated image, default value: 4194304, i.e., 20482048, generating a 2K resolution image; Value range: [10241024, 40964096], capable of generating 1K to 4K resolution images; It is recommended to generate images above 2K resolution, as images with too low a resolution are highly likely to have issues such as poor facial rendering and abnormal text; if the output of a 2K image does not meet expectations, try outputting a higher resolution image. Text-to-image scenario: Either area or width and height must be provided; if neither is provided, the default area is 20482048, generating a 2K resolution image with the model intelligently determining the aspect ratio; when both area and width and height are provided, width and height take priority; if only area is provided, the model will intelligently determine the aspect ratio based on the user's prompt intent. Image-to-image scenario: The model intelligently determines the aspect ratio based on the user's prompt intent and the reference image size.

width?integer

Width and height of the generated image; this field is not passed by default. The product of width and height must be within [10241024, 40964096], and the aspect ratio must be within [min_ratio, max_ratio]. Note: Both width and height must be passed for this to take effect. Recommended width and height options: 1K: 1024x1024 (1:1); 2K: 2048x2048 (1:1), 2304x1728 (4:3), 2496x1664 (3:2), 2560x1440 (16:9), 3024x1296 (21:9); 4K: 4096x4096 (1:1), 4694x3520 (4:3), 4992x3328 (3:2), 5404x3040 (16:9), 6198x2656 (21:9).

height?integer

Width and height of the generated image; this field is omitted by default. The product of width and height must be within [10241024, 40964096], and the aspect ratio must be within [min_ratio, max_ratio]. Note: Both width and height must be passed for this to take effect.

scale?number

The degree of influence of the text description; a larger value indicates a greater influence of the text description and a lesser influence of the input image (precision: supports two decimal places). Default value: 0.5. Value range: [0, 1].

force_single?boolean

Whether to force single image generation. Default value: false. Note: The more images generated in a set, the longer the processing time, and the generation time will increase significantly as the number of images grows; for stable multi-image output, it is recommended to use the prompt to limit the number of images to 9 or fewer; when generating multiple images, it is recommended to explicitly specify the image resolution in the prompt or directly pass specific width and height parameters to avoid API errors caused by inconsistent resolutions among the generated images.

min_ratio?number

The width/height ratio of the generated image ≥ min_ratio; if the smart aspect ratio < min_ratio, min_ratio will be used. Default: 1/3. Range: [1/16, 16).

max_ratio?number

The width/height of the generated image ≤ max_ratio; if the smart aspect ratio > max_ratio, max_ratio will be used. Default value: 3. Value range: [1/16, 16)

callback_url?string

When using asynchronous callbacks, the callback endpoint URL (must be publicly accessible)

return_url?boolean

When using asynchronous callbacks, configure whether to return image resources as URLs (valid for 24 hours). Default value: false

logo_info?string

Set watermark information when using asynchronous callbacks

aigc_meta?string

Set the implicit identifier when using asynchronous callbacks.

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 Duration in Seconds

input_tokens*integer

Input Token Count

total_tokens*integer

Total Token Count

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 "Authorization: string" \  -H "Region: string" \  -H "Service: string" \  -H "Content-Type: application/json" \  -d '{    "model": "jimeng_t2i_v40",    "req_key": "jimeng_t2i_v40",    "prompt": "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"
}