Edit
Edit enables advanced image editing through mask-based inpainting and object removal. This versatile endpoint automatically chooses the optimal processing method based on your prompt.
- Model Name:
edit - Lifecycle: experimental
- Processing Time: 12 seconds
- Supported Resolution: up to 1.05MP
- Credits: 1
- Inpainting (Prompt-Guided): When a prompt is provided, the masked area is modified to match the prompt—adding or transforming content as described.
- Contextual Fill (Promptless): When no prompt is provided, the masked area is restored using surrounding context, extending nearby patterns and textures to seamlessly repair or clean the region.
Request
Edit images by providing the source image and mask to the universal /v1/run endpoint:
Request Parameters
Required Parameters
imageRequiredimage URL | base64
Source image to be edited. The areas outside the mask will be preserved, while masked areas will be processed according to the selected mode.
Base64 images must include the proper prefix (e.g., data:image/jpg;base64,<YOUR_BASE64>)
mask_imageRequiredimage URL | base64
Mask image defining the regions to edit. White pixels mark areas for modification; black pixels preserve the original content.
Mask resolution must match the source image exactly.
- Masks are commonly produced with brush tools, where painted strokes form white regions that define editable zones.
- Leave enough surrounding context for natural blending or removal.
- Use PNG format for clean edges.
Optional Parameters
promptstring
Text description of what should be generated in the masked area. Leave empty for contextual fill.
Default: Empty string (contextual fill mode)
seedinteger
Sets random operations to a fixed state. Use the same seed to reproduce results with the same inputs, or different seed to force different results.
Default: 42
Range: 0 to 2^32 - 1
output_format'png' | 'jpeg'
Specifies the desired output image format.
-png: Delivers the highest quality image, ideal for use cases such as content creation where quality is paramount.
-jpeg: Provides a faster response with a slightly compressed image, more suitable for real-time applications.
Default: png
return_base64boolean
When set to true, the API will return the generated image as a base64-encoded string instead of a CDN URL. The base64 string will be prefixed according to the output_format (e.g., data:image/png;base64,... or data:image/jpeg;base64,...).
This option offers enhanced privacy as user-generated outputs are not stored on our servers when return_base64 is enabled.
Default: false
Response Polling
After submitting your request, poll the status endpoint using the returned prediction ID. See API Fundamentals for complete polling details.
Successful Response
When your edit operation completes successfully, the status endpoint will return:
The output array contains URLs to your edited images with the masked areas either filled with new content (inpainting) or seamlessly removed (object removal).
Runtime Errors
Edit may encounter the following model-specific errors during processing:
| Name | Cause | Solution |
|---|---|---|
ImageLoadError | The pipeline was unable to load the input image or mask image from the provided inputs. | For Image URLs:
|
InputValidationError | The mask image format or content is invalid for processing. |
|
PipelineError | An unexpected error occurred during the execution of the pipeline. | Retry the request (you will not be charged for failed attempts). If the issue persists, please reach out to us at support@fashn.ai and include the prediction ID from the failed attempt to help us locate and address the issue promptly. |
The Error Object
Example of an error when polling the /status endpoint:
If you encounter an unrecognized error, please contact us at support@fashn.ai.
Related Guides
For detailed implementation guidance and best practices:
- Image Preprocessing Best Practices - Optimize your source images and masks for editing operations