Generate Background
POST/v1/generate-background
Generates a new background for an image. Generated images are 1024x1024 by default.
Input Image Limits:
- Max size: 25MB
- Min resolution: 64x64px
- Max resolution: 6000x6000px
Request
Header Parameters
Acceptable response media type(s). application/json
or image/*
. Default is application/json
.
- application/json
- multipart/form-data
Body
URL of the image. If the image is RGB the background will automatically be removed, if the image is RGBA the background will not be removed and the alpha channel will be respected.
image_transform
object
Default value: 1
Scales the input image. Scale of 1 means the longest edge of the image fits the canvas, 1 is the default value if the background was not removed automatically. If the background was removed, the alpha around the subject is automatically trimmed so we use a scale of 0.6 to provide padding around the subject in the final image.
Default value: 0.5
Positions the horizontal center of the image within the canvas. Ranges from 0 to 1.
Default value: 0.5
Positions the vertical center of the image within the canvas. Ranges from 0 to 1.
Possible values: [marble
, wood
, industrial
, linen
, brick
, counter
]
Select a preset scene type. If provided prompt and negative_prompt will be ignored.
A description of the desired scene used to guide the image generation process.
A comma seperated list of attributes which should be discouraged in the image generation.
Body
URL of the image to be processed.
Binary file of the image to be processed, this is mutually exclusive with image_url, if both are provided the image will be used.
image_transform
object
Default value: 1
Scales the input image. Scale of 1 means the longest edge of the image fits the canvas, 1 is the default value if the background was not removed automatically. If the background was removed, the alpha around the subject is automatically trimmed so we use a scale of 0.6 to provide padding around the subject in the final image.
Default value: 0.5
Positions the horizontal center of the image within the canvas. Ranges from 0 to 1.
Default value: 0.5
Positions the vertical center of the image within the canvas. Ranges from 0 to 1.
Possible values: [marble
, wood
, industrial
, linen
, brick
, counter
]
Select a preset scene type. If provided prompt and negative_prompt will be ignored.
A description of the desired scene used to guide the image generation process.
A comma seperated list of attributes which should be discouraged in the image generation.
Responses
- 200
- 400
- 401
- 403
- 429
- 500
Success
- application/json
- image/*
- Schema
- Example (from schema)
Schema
A URL to access the resultant image which is valid for 1 hour. File format will be jpeg.
{
"result_url": "https://assets.pixelcut.app/public/result/a16646be-91c8-4e3a-b359.jpg"
}
- Schema
Schema
Resultant image in binary format. The file format will be jpeg.
The input could not be processed, often returned when the input image exceeds API limits.
- application/json
- Schema
- Example (from schema)
Schema
invalid_request_body
: The request body was empty or invalid.missing_parameter
: A required parameter was not provided.invalid_parameter
: A parameter was provided but it was invalid.unsupported_content_type
: The content type of the request was not application/json or multipart/form-data.malformed_image
: The image could not be decoded.unsupported_image_format
: The image format is not supported.file_size_too_large
: The image file size is too large.resolution_too_high
: The image resolution is too high.unknown_foreground
: The foreground subject of the image could not be detected.
A description of the error.
Possible values: [invalid_request_body
, missing_parameter
, invalid_parameter
, unsupported_content_type
, malformed_image
, unsupported_image_format
, file_size_too_large
, resolution_too_high
, unknown_foreground
]
The error codes provide a way to programmatically handle errors.
The following error codes are currently in use:
{
"error": "File size too large",
"error_code": "file_size_too_large"
}
The authentication token is missing or invalid.
- application/json
- Schema
- Example (from schema)
Schema
Possible values: [invalid_auth_token
]
{
"error": "API Token not found",
"error_code": "invalid_auth_token"
}
Returned when you have insufficient credits to perform the requested action.
- application/json
- Schema
- Example (from schema)
Schema
Possible values: [insufficient_api_credits
]
{
"error": "Insufficient credits available",
"error_code": "insufficient_api_credits"
}
Rate limit exceeded
- application/json
- Schema
- Example (from schema)
Schema
Possible values: [rate_limit_exceeded
]
{
"error": "Too many requests",
"error_code": "rate_limit_exceeded"
}
Internal service error