Skip to content

MaaS_GP_image

Request Protocol

http

Parameter Name Type Description
anthorization string Authentication

Capability Map

competence Image Generation Image Edit
Text-to-Image ✓ -
Image Editing - ✓
Multi-image Input - ✓(max. 16 photos)
Mask Editing - ✓
markup overlay - ✓ (markup.image_url only)
streaming output ✓ ✓
Multiple output formats ✓ ✓
GIF Output ✓ ✓(without mask)
SVG Output Not supported for the time being Not supported for the time being

Interface and Request Parameters

Image Generation API

POST {endpointPath}/images/generations

Generate images based on text prompts.

Request Parameters

Attribute Name Type Required or Not Description
prompt string Yes A text prompt that describes the desired image.
background string No Background behavior. Optional values: transparent (transparent, not supported by image2.0), opaque (opaque), auto (auto).
complexity string No The computation load for image planning is independent of the rendering quality. When omitted, the model default value will be used. Available options: low, medium, high.
moderation string No Content moderation level. Optional values: low, auto.
n integer No The number of images to generate. Default: 1.
output_compression number No jpegor webpformat (range: 0-100). Not supported for PNG
output_format string No Output image format. Optional values: png, jpeg, webp, gif. svgis not supported for the time being.
frame_count integer No GIF frame count, ranging from 2 to 16, default value is 9. Only valid when output_format= gif; streaming and partial_images are not supported for GIF.
frame_duration_ms integer No GIF frame interval (in milliseconds), default 200, minimum 20. Only applicable when output_format= gif.
quality string No Output image quality. Supported values: low, medium, high, auto, xhigh, max
size string No Output image size. Optional values: auto, 1024x1024, 1536x1024, 1024x1536.
On this basis, image2.0 additionally supports more flexible resolution:
Both edges must be multiples of 16 pixels; the long edge can be up to 3,840 pixels (4K): aspect ratio up to 3:1; pixel count ranging from 655,360 to 8,294,400
stream boolean No Whether to return results in streaming mode. The default value is false. Set it to true to enable streaming output.
partial_images number No Only available in streaming mode. The number of partial images during streaming response (0-3).
safety_identifier string No A stable identifier for the end user (hashed value recommended), used for security and abuse monitoring; takes precedence over userwhen non-empty. Max length: 128.
user string No A unique identifier for end users, used to monitor and detect abuse. Deprecated, please use safety_identifier instead.

Request Example

curl -X POST https://genaiapi-m2.cloudsway.net/v1/ai/{endpointPath}/images/generations \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $API_KEY" \
-d '{
  "prompt": "A beautiful sunset over mountains with vibrant colors",
  "model": "gpt-image-1", // When calling via an endpoint, the endpoint locks the model; changing the model parameter has no effect.
  "quality": "high",
  "size": "1024x1024",
  "n": 1
}'

Example of Transparent Background

curl -X POST https://genaiapi-m2.cloudsway.net/v1/ai/{endpointPath}/images/generations \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $API_KEY" \
-d '{
  "prompt": "A cute cat sitting, isolated on transparent background",
  "model": "gpt-image-1", // When calling via an endpoint, the endpoint locks the model; changing the model parameter has no effect.
  "background": "transparent",
  "output_format": "png"
}'

Example of Streaming Output

curl -X POST https://genaiapi-m2.cloudsway.net/v1/ai/{endpointPath}/images/generations \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $API_KEY" \
-d '{
  "prompt": "A futuristic cityscape at night",
  "model": "gpt-image-1", // When calling via an endpoint, the endpoint locks the model; changing the model parameter has no effect.
  "stream": true,
  "partial_images": 2
}'

Image Editing API (Image Edit)

POST {endpointPath}/images/edits

Edit or extend the existing image based on the prompt words.

Request Parameters (form-data)

Attribute Name Type Required or Not Description
image string or array Yes Upload files (you can upload multiple times, up to 16 images in total). Supported formats: jpg/png, maximum size per file: 50MB.
prompt string Yes A text prompt that describes the desired image editing effect.
background string No Output background. Optional values: transparent, opaque, auto.
complexity string No Same as the image generation API. Supported values: low, medium, high.
input_fidelity string No Fidelity to the original input image. Optional values: high, low.
mask string No Mask image file field mask, in PNG format and no larger than 4MB. Cannot be used together with markup.image_url
markup.image_url string No Transparent PNG overlay, HTTPS or base64 data URL; mutually exclusive with mask.
moderation string No content moderation. Valid values: low, auto.
model string No The model used.
n number No The number of generated edited images.
output_compression integer No jpeg/webp compression level, ranging from 0 to 100.
output_format string No Output format. Supported values: png, jpeg, webp, gif. svgis not supported for now. Mask is not supported when editing GIF.
frame_count integer No Same as image generation; only applicable when output_format= gif.
frame_duration_ms integer No Same as image generation; only output_format= gif.
partial_images number No Only available in streaming mode. This specifies the number of partial images in a streaming response, with a valid range of 0 to 3. When set to 0, a complete image is returned in a single event.
quality string No Output quality. Optional values: low, medium, high, auto, xhigh, max.
size string No Output size. Optional values: auto, 1024x1024, 1536x1024, 1024x1536.
image2.0 additionally supports more flexible resolution on this basis:
Both edges must be multiples of 16 pixels; the long edge can be up to 3,840 pixels (4K): aspect ratio up to 3:1; pixel count ranging from 655,360 to 8,294,400
stream boolean No Whether to return results in streaming mode. Defaults to false. Set to true to enable streaming output.
safety_identifier string No Same as the image generation API.
user string No Unique identifier for the end user. Deprecated, please use safety_identifier instead.
curl --location --request POST '${endpointPath}/images/edits' \
--header 'Authorization: Bearer ${your_api_key}' \
--form 'image=@"${image}"' \
--form 'prompt="Make the hair of the person in the image red"' \
--form 'stream="false"' \
--form 'background="auto"' \
--form 'output_format="jpeg"'

Image Generation Fusion Path Interface (Image Generation)

Request Path

POST http://genaiapi-m2.cloudsway.net/v1/images/generations

Call Example

curl --location 'http://genaiapi-m2.cloudsway.net/v1/images/generations' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer ${your_api_key}' \
--data '{
  "prompt": "A beautiful sunset over mountains with vibrant colors",
  "model": "MaaS_GP_image_1.5", // When calling via an endpoint, the endpoint locks the model; changing the model parameter has no effect.
  "quality": "high",
  "size": "1024x1024",
  "n": 1
}'

Image Edit Integration Path Interface (Image Edit)

Request Path

POST http://genaiapi-m2.cloudsway.net/v1/images/edits

Call Example

curl --location 'http://genaiapi-m2.cloudsway.net/v1/images/edits' \
--header 'Authorization: Bearer ${your_api_key}' \
--form 'image=@"/C:/Users/user/Desktop/apple.jpg"' \
--form 'prompt="Increase the number of apples"' \
--form 'stream="true"' \
--form 'background="auto"' \
--form 'output_format="jpeg"' \
--form 'model="MaaS_GP_image_1.5"'

Schedule

Appendix 1: Supported Output Dimensions

Dimensions aspect ratio
auto Auto
1024x1024 1:1
1536x1024 3:2
1024x1536 2:3

Appendix 2: Comparison of Model Characteristics

Features gpt-image-1.5 gpt-image-1 gpt-image-1-mini
Billing Method Token Token Token
Default response format b64_json b64_json b64_json
Streaming supported ✓ ✓ ✓
Transparent background ✓ ✓ ✓
Multi-image Input (Edit) ✓(max. 16 photos) ✓(max. 16 photos) ✓(max. 16 photos)
usage object ✓ ✓ ✓

Response Format

Non-streaming Response

Response Example

{
  "created": 1709312456,
  "background": "opaque",
  "output_format": "png",
  "quality": "high",
  "size": "1024x1024",
  "data": [
    {
      "b64_json": "iVBORw0KGgoAAAANSUhEUgAA..."
    }
  ],
  "usage": {
    "input_tokens": 1250,
    "input_tokens_details": {
      "image_tokens": 1100,
      "text_tokens": 150
    },
    "output_tokens": 4096,
    "output_tokens_details": {
      "image_tokens": 4000,
      "text_tokens": 96
    },
    "total_tokens": 5346
  }
}

Response Field Description

Field Type Description
created number Unix timestamp (in seconds) when the image was created
background string Background parameters used. Optional values: transparent, opaque
output_format string Output format. Optional values: png, webp, jpeg, gif
quality string Quality of the generated image. Supported values: low, medium, high, xhigh, max
size string Dimensions of the generated image
safety_identifier string The security identifier in effect for the request (use safety_identifier if it is not null; otherwise, use user).
data array Generated Image List
data[].b64_json string Base64-encoded image data
svg_usage object Passthrough when upstream returns SVG author usage data
usage object Token Usage Information
usage.input_tokens number Number of Input Tokens (Image + Text)
usage.input_tokens_details object Input Token Details
usage.output_tokens number Number of Output Tokens
usage.output_tokens_details object Output Token Details
usage.total_tokens number Total Token Count

Streaming Response

Response Example

event: {operation_type}.partial_image
data: {
  "type": "{operation_type}.partial_image",
  "partial_image_index": 0,
  "b64_json": "iVBORw0KGgoAAAANSUhEUgAA..."
}

event: {operation_type}.partial_image
data: {
  "type": "{operation_type}.partial_image",
  "partial_image_index": 1,
  "b64_json": "iVBORw0KGgoAAAANSUhEUgAA..."
}

event: {operation_type}.completed
data: {
  "type": "{operation_type}.completed",
  "created": 1709312456,
  "usage": {
    "input_tokens": 1250,
    "output_tokens": 4096,
    "total_tokens": 5346
  }
}
data: [DONE]

Description of Streaming Response Events

Event Type Description
{operation_type}.partial_image Returns a partially rendered image. partial_image_indexindicates which partial image the current one is (starting from 0). The number of partial images is controlled by the request parameter partial_images (range: 0-3).
{operation_type}.completed All images have been generated, and the final usage information is returned. This is the last event of the streaming response.

The value of {operation_type} can be as follows depending on the requested interface:

image_generation: /images/generations

image_edit: /images/edits

Description of Streaming Parameters

  • stream: true- Enable streaming output mode

  • partial_images: 0-3- controls the number of partial images returned

  • 0: Return the complete image directly instead of partial images

  • 1-3: Returns 1-3 partial images rendered progressively, followed by the full image

Notes

  • The complete image may be generated before all the partial images are returned.

Error Response

Example of Error Response

{
  "error": {
    "code": "invalid_api_key",
    "message": "Incorrect API key provided",
    "type": "invalid_request_error"
  }
}

Common Error Codes

Error Code Description
invalid_api_key Invalid API Key
invalid_request_error Invalid request parameters
rate_limit_exceeded Rate limit exceeded
content_policy_violation The content violates policies
server_error Internal Server Error