Skip to main content
POST
curl
Upload your picture and a mask that marks what to remove. LaMa fills the marked area using the surrounding picture. You get one PNG at the original resolution. Pixels outside the mask stay unchanged. If you set grow, this applies to the expanded mask.

Request

Send multipart/form-data. Upload the files themselves in the image and mask fields. Each file can be up to 50 MB (52,428,800 bytes). Neither side can exceed 4,096 pixels. If you set a file’s content type, use its actual image type or application/octet-stream. With the OpenAI Python SDK, pass the two open files to client.images.edit(...). Use prompt="" and send grow with extra_body={"grow": 4}.

How to mark the mask

  • If any pixel has transparency, only fully transparent pixels are removed. Partly transparent and opaque pixels are kept, whatever their color.
  • If every pixel is opaque, white or bright pixels are removed. Dark pixels are kept. On a grayscale mask, 128 through 255 mark pixels to remove.

Price

You pay 3 credits per 4 million pixels in the full picture, with a 3-credit minimum. A 4,000 × 2,000 picture has 8 million pixels and costs 6 credits, even if you mark only a small watermark. See Credits and pricing.

Response

The default response is HTTP 200. created is a Unix timestamp in seconds. Decode data[0].b64_json to save the edited PNG. The base64 below is shortened.
X-ShareMyAI-Cost-Credits gives the price. X-ShareMyAI-Balance-Credits gives your balance just after the hold. Every response includes an x-request-id.

Errors

File and field checks can fail at submission. The machine checks the decoded dimensions when it runs the edit. For an async edit, read processing errors in the failed job’s error field. For authentication, balance, concurrency and machine errors, see Errors and limits.

Authorizations

Authorization
string
header
required

An API token from the account panel on sharemy.ai. Tokens start with smai_.

Headers

Prefer
string

Send respond-async to receive a job id and poll for the result.

Body

multipart/form-data
image
file
required

Upload a PNG, JPEG or WebP. Up to 50 MB and 4,096 pixels on each side.

mask
file
required

Upload a PNG of the same dimensions, up to 50 MB. If any pixel has transparency, only fully transparent pixels are removed. In an opaque mask, bright pixels mark the removal area.

model
enum<string>
default:lama
Available options:
lama,
inpaint
response_format
string
default:b64_json
Allowed value: "b64_json"
n
integer
default:1
grow
integer
default:0

Expand the removal mask by this many pixels. A ShareMyAI extension.

Required range: 0 <= x <= 64
prompt
string

Accepted and ignored. LaMa takes no prompt.

async
boolean
default:false

Send the multipart value true to receive a job id.

Response

One edited picture.

created
integer
required

Unix time in seconds.

data
object[]
required
Required array length: 1 element