Remove Image Background
remove_backgroundRemove the background from an image, leaving the subject on a transparent (or solid color) background. Accepts an image URL, base64-encoded image or an image the user attached to the chat (PNG, JPEG, WebP or still GIF, up to 20 MB) and returns the processed image. For animated GIFs and videos use remove_video_background. Can also crop to the subject and resize the result to an exact width x height without stretching (width, height, fit). Costs 1 credit.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| fit | No | How to fit the image into width x height. 'contain' pads the remaining area (transparent or bg_color), 'cover' fills the canvas and crops the overflow around the subject, 'scale-down' is like contain but never enlarges a smaller image | contain |
| crop | No | Whether to crop the image to the subject bounds | |
| file | No | A image the user attached to the chat, as a file object with a download_url. Only use it when the client provides one for an attachment (ChatGPT does); never construct it. For a image at a public URL use image | |
| size | No | Output image size preset (megapixel cap). Ignored when width or height is set | full |
| image | No | Image input: a publicly accessible URL to a PNG, JPEG, WebP or still GIF image (including https://), or base64-encoded image data (optionally as a data: URL). Animated GIFs are videos: use remove_video_background. Set this or file | |
| width | No | Output width in pixels. On its own, the height follows the aspect ratio. With height, the image is fitted into an exact width x height canvas without stretching | |
| format | No | Output image format. 'jpg' has no transparency | png |
| height | No | Output height in pixels. On its own, the width follows the aspect ratio. With width, the image is fitted into an exact width x height canvas without stretching | |
| bg_color | No | Background color (hex, rgb, or color name). Setting it fills the background, so the result is opaque; with channels 'rgb' or format 'jpg' and no bg_color the background is white. Omit it for a transparent result. Ignored with channels 'alpha'. Example: '#ffffff' | |
| channels | No | Output color channels. Use 'rgba' for transparency, 'rgb' for an opaque background (bg_color, white by default), 'alpha' for the grayscale alpha mask only | rgba |