Image Generation
POST /v1/images/generations
Please refer to the Quickstart Guide to get your API key.
Replace $YOUR_API_KEY
with the actual API key you generated in the previous step.
Please ensure to replace $MODEL_ID
with the Model ID to be used.
Request Body
prompt string Required
The prompt text used for this image generation request.
model string Required
The Model ID used for image generation.
n integer Optional Defaults to 1
The number of images to generate simultaneously. Please note that the number of images supported may vary by model.
size string Optional Defaults to 1024x1024
The width and height pixels of the generated image, required to be between [512 x 512, 2048 x 2048]
.
Recommended optional widths and heights:
1024x1024 (1:1)
864x1152 (3:4)
1152x864 (4:3)
1280x720 (16:9)
720x1280 (9:16)
Response Parameters
model string
The Model ID used for this request (Model Name-Version).
created integer
Unix timestamp (seconds) of when this request was created.
data list
Output image information, Base64.
usage Object
Usage information for this request.
Number of images generated by the model.
output_tokens integer
Number of tokens used for images generated by the model. Calculation formula:
length*width/256
, rounded to the nearest integer.
total_tokens integer
Total number of tokens consumed by this request. Note: Since input is not tokenized,
total_tokens
is consistent with output_tokens
.
error Object
If an error occurs during this request, corresponding error information.
Please refer to the error codes.
message string
Error message.