Generate Image (Async)
curl --request POST \
--url https://api.z.ai/api/paas/v4/async/images/generations \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"model": "glm-image",
"prompt": "A cute little kitten sitting on a sunny windowsill, with the background of blue sky and white clouds.",
"size": "1280x1280"
}
'import requests
url = "https://api.z.ai/api/paas/v4/async/images/generations"
payload = {
"model": "glm-image",
"prompt": "A cute little kitten sitting on a sunny windowsill, with the background of blue sky and white clouds.",
"size": "1280x1280"
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
model: 'glm-image',
prompt: 'A cute little kitten sitting on a sunny windowsill, with the background of blue sky and white clouds.',
size: '1280x1280'
})
};
fetch('https://api.z.ai/api/paas/v4/async/images/generations', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));HttpResponse<String> response = Unirest.post("https://api.z.ai/api/paas/v4/async/images/generations")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"model\": \"glm-image\",\n \"prompt\": \"A cute little kitten sitting on a sunny windowsill, with the background of blue sky and white clouds.\",\n \"size\": \"1280x1280\"\n}")
.asString();{
"model": "<string>",
"id": "<string>",
"request_id": "<string>",
"task_status": "<string>"
}{
"code": 123,
"message": "<string>"
}Image API
Generate Image(Async)
Use the GLM-Image series models to generate high-quality images from text prompts. Through quick and accurate understanding of user text descriptions, AI image expression becomes more precise and personalized. Only supports GLM-Image model.
POST
/
paas
/
v4
/
async
/
images
/
generations
Generate Image (Async)
curl --request POST \
--url https://api.z.ai/api/paas/v4/async/images/generations \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"model": "glm-image",
"prompt": "A cute little kitten sitting on a sunny windowsill, with the background of blue sky and white clouds.",
"size": "1280x1280"
}
'import requests
url = "https://api.z.ai/api/paas/v4/async/images/generations"
payload = {
"model": "glm-image",
"prompt": "A cute little kitten sitting on a sunny windowsill, with the background of blue sky and white clouds.",
"size": "1280x1280"
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
model: 'glm-image',
prompt: 'A cute little kitten sitting on a sunny windowsill, with the background of blue sky and white clouds.',
size: '1280x1280'
})
};
fetch('https://api.z.ai/api/paas/v4/async/images/generations', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));HttpResponse<String> response = Unirest.post("https://api.z.ai/api/paas/v4/async/images/generations")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"model\": \"glm-image\",\n \"prompt\": \"A cute little kitten sitting on a sunny windowsill, with the background of blue sky and white clouds.\",\n \"size\": \"1280x1280\"\n}")
.asString();{
"model": "<string>",
"id": "<string>",
"request_id": "<string>",
"task_status": "<string>"
}{
"code": 123,
"message": "<string>"
}Body
application/json
Image size, recommended enum values: 1280x1280 (default), 1568x1056, 1056x1568, 1472x1088, 1088x1472, 1728x960, 960x1728.
Custom parameter: Both width and height must be between 1024px-2048px, and must be divisible by 32, and the maximum pixel count must not exceed 2^22px.
Example:
"1280x1280"
Response
Processing successful
Was this page helpful?