# GLM Image API

> Provider: **Z.ai**
> Source: https://www.pixazo.ai/models/glm-image

Text-to-image and image-editing model from Z.ai with accurate text rendering, style transfer, and consistent character generation across multiple reference images.

## GLM Image v1

### Text to Image

## Base URL

```
https://gateway.pixazo.ai/glm-image/v1
```

## Authentication

All requests require an API key passed via header.

Header

Type

Required

Description

Ocp-Apim-Subscription-Key

string

Yes

Your API subscription key

## GLM Image generate request - GLM Image

## Request Code

HTTP Python JavaScript cURL

```
POST https://gateway.pixazo.ai/glm-image/v1/glm-image-request
Content-Type: application/json
Cache-Control: no-cache
Ocp-Apim-Subscription-Key: YOUR_SUBSCRIPTION_KEY

{
  "prompt": "An elegant watercolor menu card painted on textured cream paper, soft turquoise washes, golden accents, dreamy bokeh background, editorial photography style",
  "image_size": "square_hd",
  "num_inference_steps": 30,
  "guidance_scale": 1.5,
  "num_images": 1,
  "enable_safety_checker": true,
  "output_format": "jpeg"
}
```

```
import requests

url = "https://gateway.pixazo.ai/glm-image/v1/glm-image-request"
headers = {
    "Content-Type": "application/json",
    "Cache-Control": "no-cache",
    "Ocp-Apim-Subscription-Key": "YOUR_SUBSCRIPTION_KEY"
}
data = {
    "prompt": "An elegant watercolor menu card painted on textured cream paper, soft turquoise washes, golden accents, dreamy bokeh background, editorial photography style",
    "image_size": "square_hd",
    "num_inference_steps": 30,
    "guidance_scale": 1.5,
    "num_images": 1,
    "enable_safety_checker": true,
    "output_format": "jpeg"
}

response = requests.post(url, json=data, headers=headers)
print(response.json())
```

```
const url = 'https://gateway.pixazo.ai/glm-image/v1/glm-image-request';
const headers = {
  'Content-Type': 'application/json',
  'Cache-Control': 'no-cache',
  'Ocp-Apim-Subscription-Key': 'YOUR_SUBSCRIPTION_KEY'
};
const data = {
  prompt: 'An elegant watercolor menu card painted on textured cream paper, soft turquoise washes, golden accents, dreamy bokeh background, editorial photography style',
  image_size: 'square_hd',
  num_inference_steps: 30,
  guidance_scale: 1.5,
  num_images: 1,
  enable_safety_checker: true,
  output_format: 'jpeg'
};

fetch(url, {
  method: 'POST',
  headers: headers,
  body: JSON.stringify(data)
})
.then(response => response.json())
.then(data => console.log(data))
.catch(error => console.error('Error:', error));
```

```
curl -X POST "https://gateway.pixazo.ai/glm-image/v1/glm-image-request" \
  -H "Content-Type: application/json" \
  -H "Cache-Control: no-cache" \
  -H "Ocp-Apim-Subscription-Key: YOUR_SUBSCRIPTION_KEY" \
  --data-raw '{
    "prompt": "An elegant watercolor menu card painted on textured cream paper, soft turquoise washes, golden accents, dreamy bokeh background, editorial photography style",
    "image_size": "square_hd",
    "num_inference_steps": 30,
    "guidance_scale": 1.5,
    "num_images": 1,
    "enable_safety_checker": true,
    "output_format": "jpeg"
  }'
```

## Output

```
{
  "images": [
    {
      "file_name": "nano-banana-pro-edit-output.png",
      "content_type": "image/png",
      "url": "[RESPONSE_URL]"
    }
  ],
  "description": ""
}
```

[Try Now](https://api.pixazo.ai/api-details#api=glm-image&operation=glm-image-request)

## Request Parameters - GLM Image generate request

Field

Type

Required

Default

Description

prompt

string

Yes

—

Text description for image generation. Must be descriptive for best results.

image\_size

string or object

No

square\_hd

Image dimensions. Allowed string enums: square\_hd, square, portrait\_4\_3, portrait\_16\_9, landscape\_4\_3, landscape\_16\_9, portrait\_3\_2, landscape\_3\_2, portrait\_hd, landscape\_hd. Custom dimensions: object with {"width": 1280, "height": 720}.

num\_inference\_steps

integer

No

30

Number of diffusion denoising steps. Higher values improve quality but increase processing time.

guidance\_scale

float

No

1.5

Classifier-free guidance scale. Controls how closely the output follows the prompt. Higher values increase prompt adherence.

seed

integer

No

—

Random seed for reproducibility. Use the same seed to generate identical outputs.

num\_images

integer

No

1

Number of images to generate in a single request.

enable\_safety\_checker

boolean

No

true

Enable NSFW content filtering. If disabled, potentially unsafe content may be generated.

output\_format

string

No

jpeg

Output image format. Allowed: jpeg, png.

sync\_mode

boolean

No

—

If true, returns base64-encoded data URI instead of a public URL. If false or omitted, returns a URL.

enable\_prompt\_expansion

boolean

No

—

If true, enhances the input prompt using an LLM to generate more detailed and higher-quality results.

## Minimum Request

```
{
  "prompt": "An elegant watercolor menu card painted on textured cream paper, soft turquoise washes, golden accents, dreamy bokeh background, editorial photography style"
}
```

## Full Request (all options)

```
{
  "prompt": "An elegant watercolor menu card painted on textured cream paper, soft turquoise washes, golden accents, dreamy bokeh background, editorial photography style",
  "image_size": "square_hd",
  "num_inference_steps": 30,
  "guidance_scale": 1.5,
  "seed": 42,
  "num_images": 1,
  "enable_safety_checker": true,
  "output_format": "jpeg",
  "sync_mode": false,
  "enable_prompt_expansion": true
}
```

## Response

```
{
  "images": [
    {
      "file_name": "nano-banana-pro-edit-output.png",
      "content_type": "image/png",
      "url": "[RESPONSE_URL]"
    }
  ],
  "description": ""
}
```

## Response Fields - GLM Image generate request

Field

Type

Description

images

array

Array of generated image objects.

file\_name

string

Name of the generated image file.

content\_type

string

MIME type of the image (e.g., image/png, image/jpeg).

url

string

Public URL to access the generated image.

description

string

Empty string placeholder for compatibility.

## Request Headers

Header

Value

Content-Type

application/json

Cache-Control

no-cache

Ocp-Apim-Subscription-Key

Your API subscription key

## Response Handling

Common status codes for GLM Image generate request.

Code

Meaning

200

Success

400

Bad Request

401

Unauthorized

403

Forbidden

404

Not Found

429

Too Many Requests

500

Internal Server Error

## Error Responses

```
{
  "error": {
    "code": "INVALID_PARAMETER",
    "message": "Invalid image_size value: invalid_size"
  }
}
```

```
{
  "error": {
    "code": "UNAUTHORIZED",
    "message": "Missing or invalid Ocp-Apim-Subscription-Key header"
  }
}
```

```
{
  "error": {
    "code": "INSUFFICIENT_FUNDS",
    "message": "Insufficient wallet balance to process request"
  }
}
```

```
{
  "error": {
    "code": "RATE_LIMIT_EXCEEDED",
    "message": "Rate limit exceeded. Retry after 60 seconds."
  }
}
```

```
{
  "error": {
    "code": "INTERNAL_ERROR",
    "message": "Internal server error. Please retry later."
  }
}
```

## Status Values

Status

Description

QUEUED

Request accepted, waiting to be processed

PROCESSING

Being processed by the model

COMPLETED

Done — output contains the result

FAILED

Failed — check error field for details

ERROR

System error — request was not processed and not charged

## Status Flow

QUEUED → PROCESSING → (COMPLETED / FAILED / ERROR)

## Typical Workflow

1.  Submit a request to `/glm-image-request` to get a `request_id`
2.  Wait 2–3 seconds, then send a GET request to `/v2/requests/status/{request_id}`
3.  Repeat polling every 2–3 seconds until status is COMPLETED, FAILED, or ERROR
4.  If COMPLETED, use `output.media_url[0]` to retrieve the generated image
5.  Implement exponential backoff for ERROR or 500 responses

## GLM Image check status - GLM Image

## Request Code

HTTP Python JavaScript cURL

```
POST https://gateway.pixazo.ai/v2/requests/status/glm-image_019dxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
Ocp-Apim-Subscription-Key: YOUR_SUBSCRIPTION_KEY

{
  "request_id": "glm-image_019dxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
}
```

```
import requests

url = "https://gateway.pixazo.ai/v2/requests/status/glm-image_019dxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
headers = {
    "Ocp-Apim-Subscription-Key": "YOUR_SUBSCRIPTION_KEY"
}
data = {
    "request_id": "glm-image_019dxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
}

response = requests.post(url, json=data, headers=headers)
print(response.json())
```

```
const url = 'https://gateway.pixazo.ai/v2/requests/status/glm-image_019dxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx';
const headers = {
  'Ocp-Apim-Subscription-Key': 'YOUR_SUBSCRIPTION_KEY'
};
const data = {
  request_id: 'glm-image_019dxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx'
};

fetch(url, {
  method: 'POST',
  headers: headers,
  body: JSON.stringify(data)
})
.then(response => response.json())
.then(data => console.log(data))
.catch(error => console.error('Error:', error));
```

```
curl -X POST "https://gateway.pixazo.ai/v2/requests/status/glm-image_019dxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" \
  -H "Ocp-Apim-Subscription-Key: YOUR_SUBSCRIPTION_KEY" \
  --data-raw '{
    "request_id": "glm-image_019dxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
  }'
```

## Output

```
{
  "images": [
    {
      "file_name": "nano-banana-pro-edit-output.png",
      "content_type": "image/png",
      "url": "[RESPONSE_URL]"
    }
  ],
  "description": ""
}
```

## Request Parameters - GLM Image check status

Field

Type

Required

Default

Description

request\_id

string

Yes

—

The unique identifier returned from the initial /glm-image-request call.

## Minimum Request

```
{
  "request_id": "glm-image_019dxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
}
```

## Full Request

```
{
  "request_id": "glm-image_019dxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
}
```

## Response

```
{
  "images": [
    {
      "file_name": "nano-banana-pro-edit-output.png",
      "content_type": "image/png",
      "url": "[RESPONSE_URL]"
    }
  ],
  "description": ""
}
```

## Response Fields - GLM Image check status

Field

Type

Description

images

array

Array of generated image objects.

file\_name

string

Name of the generated image file.

content\_type

string

MIME type of the image (e.g., image/png, image/jpeg).

url

string

Public URL to access the generated image.

description

string

Empty string placeholder for compatibility.

## Request Headers

Header

Value

Ocp-Apim-Subscription-Key

Your API subscription key

## Response Handling

Common status codes for GLM Image check status.

Code

Meaning

200

Success

400

Bad Request

401

Unauthorized

404

Not Found

429

Too Many Requests

500

Internal Server Error

## Notes & Tips

-   Poll the status endpoint every 2–3 seconds until COMPLETED, FAILED, or ERROR is returned.
-   Implement exponential backoff for retry logic on ERROR or 500 responses.
-   Use detailed, descriptive prompts with specific styles, lighting, and composition cues for optimal results.
-   Set a seed value to reproduce identical outputs for iterative refinement.
-   Use enable\_prompt\_expansion: true for complex scenes to improve detail and coherence.
-   Prefer output\_format: "png" for images requiring transparency or lossless quality.
-   Avoid overly long prompts exceeding 500 characters for best performance.
-   Processing time typically ranges from 5–15 seconds depending on complexity.
-   Multiple images (num\_images > 1) may increase processing time proportionally.

### Image to Image

## Base URL

```
https://gateway.pixazo.ai/glm-image-image-to-image/v1
```

## Authentication

All requests require an API key passed via header.

Header

Type

Required

Description

Ocp-Apim-Subscription-Key

string

Yes

Your API subscription key

## GLM Image (Image to Image) generate request - GLM Image (Image to Image)

## Request Code

HTTP Python JavaScript cURL

```
POST https://gateway.pixazo.ai/glm-image-image-to-image/v1/glm-image-image-to-image-request
Content-Type: application/json
Cache-Control: no-cache
Ocp-Apim-Subscription-Key: YOUR_SUBSCRIPTION_KEY

{
  "prompt": "Make the dress red.",
  "image_urls": [
    "https://example.com/example_inputs/catwalk.png"
  ]
}
```

```
import requests

url = "https://gateway.pixazo.ai/glm-image-image-to-image/v1/glm-image-image-to-image-request"
headers = {
    "Content-Type": "application/json",
    "Cache-Control": "no-cache",
    "Ocp-Apim-Subscription-Key": "YOUR_SUBSCRIPTION_KEY"
}
data = {
    "prompt": "Make the dress red.",
    "image_urls": [
        "https://example.com/example_inputs/catwalk.png"
    ]
}

response = requests.post(url, json=data, headers=headers)
print(response.json())
```

```
const url = "https://gateway.pixazo.ai/glm-image-image-to-image/v1/glm-image-image-to-image-request";
const headers = {
  "Content-Type": "application/json",
  "Cache-Control": "no-cache",
  "Ocp-Apim-Subscription-Key": "YOUR_SUBSCRIPTION_KEY"
};
const data = {
  prompt: "Make the dress red.",
  image_urls: [
    "https://example.com/example_inputs/catwalk.png"
  ]
};

fetch(url, {
  method: "POST",
  headers: headers,
  body: JSON.stringify(data)
})
.then(response => response.json())
.then(data => console.log(data))
.catch(error => console.error("Error:", error));
```

```
curl -X POST "https://gateway.pixazo.ai/glm-image-image-to-image/v1/glm-image-image-to-image-request" \
  -H "Content-Type: application/json" \
  -H "Cache-Control: no-cache" \
  -H "Ocp-Apim-Subscription-Key: YOUR_SUBSCRIPTION_KEY" \
  --data-raw '{
    "prompt": "Make the dress red.",
    "image_urls": [
      "https://example.com/example_inputs/catwalk.png"
    ]
  }'
```

## Output

```
{
  "images": [
    {
      "file_name": "nano-banana-pro-edit-output.png",
      "content_type": "image/png",
      "url": "[RESPONSE_URL]"
    }
  ],
  "description": ""
}
```

[Try Now](https://api.pixazo.ai/api-details#api=glm-image-image-to-image&operation=glm-image-image-to-image-request)

## Request Parameters - GLM Image (Image to Image) generate request

Field

Type

Required

Default

Description

prompt

string

Yes

—

Text prompt describing the desired image edit or transformation. Must be detailed for best results.

image\_urls

string\[\]

Yes

—

Array of URLs (up to 4) pointing to condition images used for image-to-image generation. These guide the editing process.

image\_size

enum or object

No

square\_hd

Output image dimensions. Allowed enum values: square\_hd, square, portrait\_4\_3, portrait\_16\_9, landscape\_4\_3, landscape\_16\_9, portrait\_3\_2, landscape\_3\_2, portrait\_hd, landscape\_hd. Custom size: provide object {"width": 1280, "height": 720}.

num\_inference\_steps

integer

No

30

Number of diffusion denoising steps. Higher values improve quality but increase processing time.

guidance\_scale

float

No

1.5

Classifier-free guidance scale. Controls how closely the output follows the prompt. Values typically range from 1.0 to 3.0.

seed

integer

No

—

Random seed for reproducible results. Use the same seed with identical inputs to generate identical outputs.

num\_images

integer

No

1

Number of images to generate in a single request.

enable\_safety\_checker

boolean

No

true

Enable NSFW content filtering. If enabled, outputs containing unsafe content will be blocked or flagged.

output\_format

enum

No

jpeg

Output image format. Allowed values: jpeg, png.

sync\_mode

boolean

No

—

If true, returns base64-encoded data URI instead of a public URL. Use for low-latency, direct embedding.

enable\_prompt\_expansion

boolean

No

—

If true, enhances the input prompt using an LLM to add context, detail, and stylistic cues for improved generation.

## Minimum Request

```
{
  "prompt": "Make the dress red.",
  "image_urls": [
    "https://example.com/example_inputs/catwalk.png"
  ]
}
```

## Full Request (all options)

```
{
  "prompt": "Make the dress red.",
  "image_urls": [
    "https://example.com/example_inputs/catwalk.png"
  ],
  "image_size": "square_hd",
  "num_inference_steps": 30,
  "guidance_scale": 1.5,
  "seed": 42,
  "num_images": 1,
  "enable_safety_checker": true,
  "output_format": "jpeg",
  "sync_mode": false,
  "enable_prompt_expansion": false
}
```

## Response

```
{
  "images": [
    {
      "file_name": "nano-banana-pro-edit-output.png",
      "content_type": "image/png",
      "url": "[RESPONSE_URL]"
    }
  ],
  "description": ""
}
```

## Response Fields - GLM Image (Image to Image) generate request

Field

Type

Description

images

array

Array of generated images, each with file\_name, content\_type, and url.

file\_name

string

Name of the generated image file.

content\_type

string

MIME type of the image (e.g., image/png, image/jpeg).

url

string

URL to download the generated image.

description

string

Empty string placeholder for compatibility.

## Request Headers

Header

Value

Content-Type

application/json

Cache-Control

no-cache

Ocp-Apim-Subscription-Key

Your API subscription key

## Response Handling

Common status codes for GLM Image (Image to Image) generate request.

Code

Meaning

200

Success

400

Bad Request

401

Unauthorized

403

Forbidden

404

Not Found

429

Too Many Requests

500

Internal Server Error

## Error Responses

### 400 Validation Error

```
{
  "error": "Missing required parameter: prompt",
  "code": "VALIDATION_ERROR"
}
```

### 404 Not Found

```
{
  "error": "Operation not found",
  "code": "NOT_FOUND"
}
```

## Status Handling

Polling status values for GLM Image (Image to Image) generate request.

Status

Description

QUEUED

Request accepted, waiting to be processed

PROCESSING

Being processed by the model

COMPLETED

Done — output contains the result

FAILED

Failed — check error field for details

ERROR

System error — request was not processed and not charged

### Status Flow

QUEUED → PROCESSING → (COMPLETED or FAILED or ERROR)

### Typical Workflow

1.  Submit request to `/glm-image-image-to-image-request` and receive a `request_id`.
2.  Poll the status endpoint `/glm-image-image-to-image-request-result` every 2–3 seconds using the `request_id`.
3.  Continue polling until response status is COMPLETED, FAILED, or ERROR.
4.  When COMPLETED, extract the image URL from the response and download the result.

## GLM Image (Image to Image) check status - GLM Image (Image to Image)

## Request Code

HTTP Python JavaScript cURL

```
POST https://gateway.pixazo.ai/glm-image-image-to-image/v1/glm-image-image-to-image-request-result
Content-Type: application/json
Ocp-Apim-Subscription-Key: YOUR_SUBSCRIPTION_KEY

{
  "request_id": "glm-image-image-to-image_019dxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
}
```

```
import requests

url = "https://gateway.pixazo.ai/glm-image-image-to-image/v1/glm-image-image-to-image-request-result"
headers = {
    "Content-Type": "application/json",
    "Ocp-Apim-Subscription-Key": "YOUR_SUBSCRIPTION_KEY"
}
data = {
    "request_id": "glm-image-image-to-image_019dxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
}

response = requests.post(url, json=data, headers=headers)
print(response.json())
```

```
const url = "https://gateway.pixazo.ai/glm-image-image-to-image/v1/glm-image-image-to-image-request-result";
const headers = {
  "Content-Type": "application/json",
  "Ocp-Apim-Subscription-Key": "YOUR_SUBSCRIPTION_KEY"
};
const data = {
  request_id: "glm-image-image-to-image_019dxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
};

fetch(url, {
  method: "POST",
  headers: headers,
  body: JSON.stringify(data)
})
.then(response => response.json())
.then(data => console.log(data))
.catch(error => console.error("Error:", error));
```

```
curl -X POST "https://gateway.pixazo.ai/glm-image-image-to-image/v1/glm-image-image-to-image-request-result" \
  -H "Content-Type: application/json" \
  -H "Ocp-Apim-Subscription-Key: YOUR_SUBSCRIPTION_KEY" \
  --data-raw '{
    "request_id": "glm-image-image-to-image_019dxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
  }'
```

## Output

```
{
  "images": [
    {
      "file_name": "nano-banana-pro-edit-output.png",
      "content_type": "image/png",
      "url": "[RESPONSE_URL]"
    }
  ],
  "description": ""
}
```

[Try Now](https://api.pixazo.ai/api-details#api=glm-image-image-to-image&operation=glm-image-image-to-image-request-result)

## Request Parameters - GLM Image (Image to Image) check status

Field

Type

Required

Default

Description

request\_id

string

Yes

—

The unique identifier returned from the initial request to /glm-image-image-to-image-request.

## Minimum Request

```
{
  "request_id": "glm-image-image-to-image_019dxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
}
```

## Full Request (all options)

```
{
  "request_id": "glm-image-image-to-image_019dxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
}
```

## Response

```
{
  "images": [
    {
      "file_name": "nano-banana-pro-edit-output.png",
      "content_type": "image/png",
      "url": "[RESPONSE_URL]"
    }
  ],
  "description": ""
}
```

## Response Fields - GLM Image (Image to Image) check status

Field

Type

Description

images

array

Array of generated images, each with file\_name, content\_type, and url.

file\_name

string

Name of the generated image file.

content\_type

string

MIME type of the image (e.g., image/png, image/jpeg).

url

string

URL to download the generated image.

description

string

Empty string placeholder for compatibility.

## Request Headers

Header

Value

Content-Type

application/json

Ocp-Apim-Subscription-Key

Your API subscription key

## Response Handling

Common status codes for GLM Image (Image to Image) check status.

Code

Meaning

200

Success

400

Bad Request

401

Unauthorized

403

Forbidden

404

Not Found

429

Too Many Requests

500

Internal Server Error

## Notes & Tips

-   Poll the status endpoint every 2–3 seconds until COMPLETED, FAILED, or ERROR is returned.
-   Implement exponential backoff for retrying failed or timed-out requests.
-   Use detailed, descriptive prompts with specific color, texture, and style references for best results.
-   For multi-image conditioning, ensure all reference images are high-resolution and clearly depict the elements to be preserved.
-   Use enable\_prompt\_expansion for ambiguous prompts to improve generation quality.
-   Prefer output\_format: png for edits requiring transparency or lossless quality.
-   Set a seed value when reproducibility is required across multiple runs.
