Outpaint

The Outpaint service inserts additional content in an image to fill in the space in any direction. Compared to other automated or manual attempts to expand the content in an image, the Outpaint service should minimize artifacts and signs that the original image has been edited.

Credits

The service uses 8 credits per successful result. You will not be charged for failed results.

Example Request and Response

API Documentation

API EndpointMethod
/api/edit/outpaintPOST

Request Header

ParameterDescription
AuthenticationUse your API key to authentication requests to this App.

Request Body

The request should include a JSON object in the body with the following parameters:

ParameterTypeRequiredDescription
imagestring <binary>Yes

The image you wish to outpaint.Supported Formats:jpeg、png、webp

left、right、up、integerNo

The number of pixels to outpaint on the left side of the image. At least one outpainting direction must be supplied with a non-zero value.

creativitynumberNo

[ 0 .. 1 ] Default: 0.5. Controls the likelihood of creating additional details not heavily conditioned by the init image.

promptstringNo

What you wish to see in the output image. A strong, descriptive prompt that clearly defines elements, colors, and subjects will lead to better results.

seednumberNo

[ 0 .. 4294967294 ], A specific value that is used to guide the 'randomness' of the generation. (Omit this parameter or pass 0 to use a random seed.)

output_formatstringNo

Enum: jpeg png webp

Response Body

The response should include a JSON object in the body with the following parameters:

ParameterTypeDescription
codeintStatus Code, 0 for success callback, -1 for failure callback
messagestringCallback message, 'success' for success, failure reason for failure
dataobjectImage Details

Image Details

ParameterTypeDescription
imagestringReturn the base64 encoded image of the generated picture.
seedintThe seed used as random noise for this generation.

Example Request

import requests

response = requests.post(
    f"https://www.aithriving.com/api/edit/outpaint",
    headers={
        "authorization": f"your-auth-token"
    },
    files={
        "image": open("./your-image.png", "rb")
    },
    data={
        "left": 200,
        "down": 200,
        "output_format": "webp"
    },
)

if response.status_code == 200:
    data = response.json()
    if data['code'] == 0:
        // image: data['data']['image']
    else:
        // error
else:
    raise Exception(str(response.json()))

Example Response

{
  "code": 0,
  "message": "success",
  "data": "base64 encoded image data"
}