MaaS Image-1 Interface Documentation
Request Protocol
HTTP
Generate Images:
Header
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 | Type | Description |
---|---|---|
prompt | string | Text description of the desired image. The maximum length is 32,000 characters. |
background | 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 | string | Model name |
moderation | string | Controls the content review level of the generated images. Must be low (for less restrictive filtering) or auto (default). |
n | int | Number of images to generate. Must be between 1 and 10. |
output_compression | 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 | string | Format of the returned generated images. Must be one of png , jpeg , or webp . |
quality | string | Quality of the generated images. - auto (default) will automatically select the best quality for the given model. - Supports high , medium , and low . |
size | string | Size of the generated images. Must be one of "1024x1024", "1536x1024" (landscape), "1024x1536" (portrait), or "auto" (default). |
user | 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 | Type | Description |
---|---|---|
image | 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 | string | Text description of the desired image. The maximum length is 32,000 characters. |
background | 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 | 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 | string | Model name |
n | int | Number of images to generate. Must be between 1 and 10. |
quality | string | Quality of the generated images. - auto (default) will automatically select the best quality for the given model. - Supports high , medium , and low . |
size | string | Size of the generated images. Must be one of "1024x1024", "1536x1024" (landscape), "1024x1536" (portrait), or "auto" (default). |
user | 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
}
}
}