Skip to main content
POST
/
paas
/
v4
/
images
/
generations
Generate Image
curl --request POST \
  --url https://api.z.ai/api/paas/v4/images/generations \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '{
  "model": "cogView-4-250304",
  "prompt": "A cute little kitten sitting on a sunny windowsill, with the background of blue sky and white clouds.",
  "size": "1024x1024"
}'
{
  "created": 1760335349,
  "data": [
    {
      "url": "<string>"
    }
  ],
  "content_filter": [
    {
      "role": "assistant",
      "level": 1
    }
  ]
}

Authorizations

Authorization
string
header
required

Use the following format for authentication: Bearer <your api key>

Body

application/json
model
enum<string>
required

Model code

Available options:
cogview-4-250304
Example:

"cogview-4-250304"

prompt
string
required

The text description of the image to be generated.

Example:

"A cute little kitten."

quality
enum<string>
default:standard

The quality of the generated image. Default is standard. hd: Generates a more detailed and rich image with higher overall consistency, but takes about 20 seconds. standard: Generates an image quickly, suitable for scenarios with higher requirements for generation speed, takes about 5-10 seconds. This parameter is only supported for cogview-4-250304.

Available options:
hd,
standard
size
string
default:1024x1024

Image size, default is 1024x1024, recommended enum values: 1024x1024 (default), 768x1344, 864x1152, 1344x768, 1152x864, 1440x720, 720x1440. Custom parameter: Both width and height must be between 512px-2048px, and must be divisible by 16, and the maximum pixel count must not exceed 2^21px.

Example:

"1024x1024"

user_id
string

Unique ID of the end user, helping the platform intervene in illegal activities, inappropriate content generation, or other abuses. ID length: 6 to 128 characters.

Required string length: 6 - 128

Response

Processing successful

created
integer

Request creation time, in Unix timestamp format, unit is seconds.

Example:

1760335349

data
object[]

Array, containing the generated image URL. Currently, the array only contains one image.

content_filter
object[]

Array, containing content safety related information.

⌘I