# Remove background

> Turn one image into a cutout with a transparent background. No model or prompt to choose.

`POST /image/remove-background` takes one image URL and returns a cutout with
a transparent background. There is no `model` field and no prompt. Mynth picks
the model and keeps it current.

**SDK**

```ts
import Mynth from "@mynthio/sdk";

const mynth = new Mynth();

const cutout = await mynth.image.removeBackground({
  url: "https://cdn.example.com/product.jpg",
  output: { format: "png" },
});

console.log(cutout.image.url);
```

**CLI**

```bash
npx @mynthio/cli image remove-background https://cdn.example.com/product.jpg -f png -o ./out
```

**REST**

```bash
curl https://api.mynth.io/image/remove-background \
  -H "Authorization: Bearer $MYNTH_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"url":"https://cdn.example.com/product.jpg","output":{"format":"png"}}'
```

## Fields

| Field           | Notes                                                                          |
| --------------- | ------------------------------------------------------------------------------ |
| `url`           | Required. A public http(s) image URL                                           |
| `output.format` | `png` or `webp`. Both keep transparency. Omit it for the provider's format     |
| `destination`   | A destination name. See [destinations](https://mynth.io/docs/concepts/destinations.md)            |
| `webhook`       | Per-request URLs. See [webhooks](https://mynth.io/docs/concepts/webhooks.md#per-request-webhooks) |
| `metadata`      | A JSON object up to 2048 bytes                                                 |
| `access`        | `{ "pat": { "enabled": false } }` skips the browser token                      |

For a local file, pass `file` instead of `url` in the SDK, or a path in the
CLI. Both upload it first.

## What comes back

```json
{
  "image": {
    "id": "img_Q8mZr2LkT0vWc5NhY7pD3xFa9GsJ1bEu",
    "url": "https://cdn.mynth.io/images/img_Q8mZr2LkT0vWc5NhY7pD3xFa9GsJ1bEu.png",
    "mynth_url": "https://cdn.mynth.io/images/img_Q8mZr2LkT0vWc5NhY7pD3xFa9GsJ1bEu.png",
    "size": "1024x1024",
    "format": "png"
  }
}
```

There is one image and no per-item status. If the work fails, the task is
`failed`. With a destination, `image` also carries a `destination` block that
says whether the upload worked. See
[destinations](https://mynth.io/docs/concepts/destinations.md#what-comes-back).

The create response includes a `pat_` token, so a browser can poll this task
the same way it polls a generation. See
[poll for results](https://mynth.io/docs/guides/poll-for-results.md#from-a-browser).

## Price

$0.02 per image, held at create and charged when the task succeeds. See
[pricing](https://mynth.io/docs/pricing.md#tool-prices).

## Next steps

- [Destinations](https://mynth.io/docs/concepts/destinations.md): write the cutout to your own storage.
- [Image to image](https://mynth.io/docs/guides/image-to-image.md): edits that need a prompt.
