Skip to main content

Text Inpainting

Text Inpainting API

To replace an object in your pictures, you can use the API available at https://clipdrop-api.co/text-inpainting/v1.

The request must be an http POST and its body must be a multipart/form-data that has two images files:

  • a required image_file is the original image to process.
    • The original image should be a JPG or a PNG, with a maximum resolution of 10 megapixels and a max file size of 30 Mb.
  • a required mask_file is the mask image, defining the areas that need to be removed.
    • The mask image should be a PNG, and should have the same resolution as the original image and a max file size of 30 Mb.
    • The mask should be black and white with no grey pixels (e.g. values of only 0 or 255), the value of 0 indicating a pixel to keep as is and 255 a pixel to 'replace'
  • a required text_prompt text field describing what you want to put in the image.
note

If you want to remove an object from your picture, you can use the Cleanup API.

In case of success:

  • the response mime-type is image/jpeg and the response image is a JPEG image with the same dimensions as the image_file.
  • the response headers will include a x-remaining-credits property to tell you how many credits you have left and a x-credits-consumed property to tell you how many credits were consumed by your request.

In case of an error:

  • the response mime-type is application/json, error type is indicated by the response status code and details are in the json body, ie
{ "error": "No api key provided" }

Authentication

Requests are authenticated with an API key. If you need one, please contact us at contact@clipdrop.co.

If your key has leaked, you can revoke it and request a new one in your account page.

Credits

1 successful text inpainting API call = 1 credit.

Once logged in, you can claim 100 free Clipdrop APIs credits that you can use for development and debugging purposes. Once the 100 images have been consumed, further calls will be rejected.

If you need more credits, you can purchase more credits via the following link.

Quota / Rate limiting

By default, each API key has a limit of 30 requests per minute for the text inpainting API. Please let us know if you'd like higher values.

Examples

curl -X POST https://clipdrop-api.co/text-inpainting/v1 \
-H 'x-api-key: YOUR_API_KEY' \
-F 'image_file=@image.jpg' \
-F 'mask_file=@mask.png' \
-F 'text_prompt="A woman with a red scarf"' \
-o result.png

Responses

The result image, e.g. 
Example result showing a woman with a red scarf

Examples of input and outputs

image_file

photo.jpg

mask_file

mask.png

result

photo_inpainting.jpg

Support

Any question ? Contact us at contact@clipdrop.co or join the Slack community.