Skip to content

MaaS Image-1 Interface Documentation

Request Protocol

HTTP

Generate Images:

Parameter Name Value
Authorization Bearer {YOUR AK}
Content-Type application/json

Request URL

https://genaiapi.cloudsway.net/v1/ai/{YOUR ENDPOINT}/images/generations

Request Body:

Parameter Name Required Type Description
prompt YES string Text description of the desired image. The maximum length is 32,000 characters.
background NO string Allows setting the transparency of the generated image background. Must be one of transparent, opaque, or auto (default). When using auto, the model will automatically determine the best background for the image.
If it is "transparent", the output format needs to support transparency, so it should be set to "png" (default) or "webp".
model YES string Model name
moderation NO string Controls the content review level of the generated images. Must be low (for less restrictive filtering) or auto (default).
n NO int Number of images to generate. Must be between 1 and 10.
output_compression NO int Compression level of the generated images (0 - 100%). This parameter only applies when the output format is webp or jpeg, and the default is 100.
output_format NO string Format of the returned generated images. Must be one of png, jpeg, or webp.
quality NO string Quality of the generated images.
- auto (default) will automatically select the best quality for the given model.
- Supports high, medium, and low.
size NO string Size of the generated images. Must be one of "1024x1024", "1536x1024"
(landscape), "1024x1536" (portrait), or "auto" (default).
user NO string A unique identifier representing the end user

Request Example

curl --location 'https://genaiapi.cloudsway.net/v1/ai/{YOUR ENDPOINT}/images/generations' \
--header 'Authorization: Bearer {YOUR AK}' \
--header 'Content-Type: application/json' \
--data '{
    "prompt": "A photograph of a black fox in an autumn forest",
    "size": "1024x1024",
    "quality": "medium",
    "output_compression": 100,
    "output_format": "png",
    "n": 1
}
'

Response Results:

Parameter Name Type Description
created int Unix timestamp (in seconds) when the image was created.
data List[Image] List of generated images
usage Usage Token usage information for image generation.

Image:

Parameter Name Type Description
b64_json string Base64-encoded JSON of the generated image.

Usage:

Parameter Name Type Description
input_tokens int Number of tokens in the input prompt (images or text)
input_tokens_details UsageInputTokensDetails Details of the input tokens for image generation
output_tokens int Number of output image tokens
total_tokens int Total number of tokens for image generation

UsageInputTokensDetails:

Parameter Name Type Description
image_tokens int Number of input image tokens
text_tokens int Number of input text tokens

Example

{
    "created": 1747972711,
    "data": [
        {
            "b64_json": "iVBORw0KGgoAAAANSUhEU..."
        }
    ],
    "usage": {
        "input_tokens": 252,
        "output_tokens": 4160,
        "total_tokens": 4412,
        "input_tokens_details": {
            "image_tokens": 194,
            "text_tokens": 58
        }
    }
}

Edit Images:

Header

Parameter Name Value
Authorization Bearer {YOUR AK}
Content-Type multipart/form-data

Request URL

https://genaiapi.cloudsway.net/v1/ai/{YOUR ENDPOINT}/images/edits

Request Body:

Parameter Name Required Type Description
image YES File Image to be edited. Must be a supported image file or an array of images.
Each image should be a 'png', 'webp', or 'jpg' file smaller than 25MB, and you can provide up to 16 images at most.
prompt YES string Text description of the desired image. The maximum length is 32,000 characters.
background NO string Allows setting the transparency of the generated image background. Must be one of transparent, opaque, or auto (default). When using auto, the model will automatically determine the best background for the image.
If it is "transparent", the output format needs to support transparency, so it should be set to "png" (default) or "webp".
mask NO File Additional image with fully transparent areas (e.g., alpha is zero)
- Indicates where the 'image' should be edited. If multiple images are provided, the mask will be applied to the first image. Must be a valid PNG file, smaller than 4MB, and have the same dimensions as the 'image'.
model YES string Model name
n NO int Number of images to generate. Must be between 1 and 10.
quality NO string Quality of the generated images.
- auto (default) will automatically select the best quality for the given model.
- Supports high, medium, and low.
size NO string Size of the generated images. Must be one of "1024x1024", "1536x1024"
(landscape), "1024x1536" (portrait), or "auto" (default).
user NO string A unique identifier representing the end user

Request Example

curl --location 'https://genaiapi.cloudsway.net/v1/ai/{YOUR ENDPOINT}/images/edits' \
--header 'Authorization: Bearer {YOUR AK}' \
--header 'Content-Type: multipart/form-data' \
--form 'image=@"/C:/Desktop/fox.png"' \
--form 'prompt="generate a mask delimiting the entire character in the picture, using white where the character is and black for the background. Return an image in the same size as the input image."'

Return Results

Parameter Name Type Description
created int Unix timestamp (in seconds) when the image was created.
data List[Image] List of generated images
usage Usage Token usage information for image generation.

Image:

Parameter Name Type Description
b64_json string Base64-encoded JSON of the generated image.

Usage:

Parameter Name Type Description
input_tokens int Number of tokens in the input prompt (images or text)
input_tokens_details UsageInputTokensDetails Details of the input tokens for image generation
output_tokens int Number of output image tokens
total_tokens int Total number of tokens for image generation

UsageInputTokensDetails:

Parameter Name Type Description
image_tokens int Number of input image tokens
text_tokens int Number of input text tokens

Example

{
    "created": 1748228315,
    "data": [
        {
            "b64_json": "iVBORw0KGgoAAA..."
        }
    ],
    "usage": {
        "input_tokens": 252,
        "output_tokens": 4160,
        "total_tokens": 4412,
        "input_tokens_details": {
            "image_tokens": 194,
            "text_tokens": 58
        }
    }
}