<!-- remove.bg API migration guide: a drop-in replacement in one URL change — Cutmatte. Source: https://cutmatte.com/migrate/ -->

# remove.bg API migration guide

To get code that calls `api.remove.bg` working again after 1 December 2026, replace `https://api.remove.bg` with `https://api.cutmatte.com` and use a Cutmatte key. remove.bg closed its self-serve API that day; Cutmatte takes the same requests and sends the same responses. Other options are in our [comparison of remove.bg API alternatives](https://cutmatte.com/remove-bg-api-alternative/).

Updated 1 December 2026.

On this page: [cURL](https://cutmatte.com/migrate/#curl) · [Node.js](https://cutmatte.com/migrate/#node) · [axios](https://cutmatte.com/migrate/#axios) · [Python](https://cutmatte.com/migrate/#python) · [PHP](https://cutmatte.com/migrate/#php) · [Laravel](https://cutmatte.com/migrate/#laravel) · [Ruby](https://cutmatte.com/migrate/#ruby) · [C#](https://cutmatte.com/migrate/#csharp) · [Java](https://cutmatte.com/migrate/#java) · [n8n](https://cutmatte.com/migrate/#n8n) · [Zapier and Make](https://cutmatte.com/migrate/#zapier-make) · [WordPress](https://cutmatte.com/migrate/#wordpress) · [npm, PyPI, CLI, Ruby, .NET](https://cutmatte.com/migrate/#libraries) · [every parameter](https://cutmatte.com/migrate/#parameters) · [troubleshooting](https://cutmatte.com/migrate/#troubleshooting) · [limits](https://cutmatte.com/migrate/#limits) · [questions](https://cutmatte.com/migrate/#faq) · [Leonardo.Ai compared](https://cutmatte.com/migrate/#leonardo)

## Three steps

1. [Sign in](https://cutmatte.com/dashboard/) with your email and create an API key.
2. Replace `https://api.remove.bg` with `https://api.cutmatte.com`.
3. Use the new key in the same `X-Api-Key` header.

Parameters, response formats, headers such as `X-Credits-Charged` and `X-Width`, and error codes stay the same. The few features we do not have are listed in [differences](https://cutmatte.com/docs/#differences).

## Find every remove.bg call

Calls hide in more places than the main code. Run these in each repository:

```
grep -rn "api.remove.bg" .                                  # direct calls and config
grep -rn "REMOVE_BG\|REMOVEBG" .                            # environment variables
grep -n '"remove.bg"' package.json                           # npm wrapper
grep -in "removebg" requirements*.txt pyproject.toml         # PyPI wrapper
grep -n "mtownsend/remove-bg" composer.json                  # Laravel wrapper
grep -n "remove_bg" Gemfile                                  # Ruby gem
```

Then check what grep cannot see: CI secrets, cron jobs, Zapier, Make and n8n flows, shop and CMS plugins with a remove.bg key field, and desktop tools such as GIMP or Photoshop plugins.

## Let your coding agent do it

If Claude Code, Cursor or Copilot maintains your code, paste this prompt. A plain-text copy of this guide is at [/migrate.md](https://cutmatte.com/migrate.md).

```
Migrate this project from the remove.bg API to Cutmatte.
1. Find every call to https://api.remove.bg: code, config, environment variables,
   CI, and wrappers (npm "remove.bg", PyPI "removebg", Laravel "mtownsend/remove-bg",
   Ruby "remove_bg").
2. Replace the base URL with https://api.cutmatte.com. Read the key from a
   CUTMATTE_API_KEY environment variable and send it in the same X-Api-Key header.
3. Do not change parameters, response handling or error handling.
4. Set the HTTP timeout for these calls to at least 60 seconds.
Reference: https://cutmatte.com/migrate.md and https://cutmatte.com/docs.md
```

## Before you switch production

1. **Run your usual images in a staging environment.** Expect the same response as before: the image itself, or JSON with `result_b64` when you send `Accept: application/json`, plus the `X-Width`, `X-Height` and `X-Credits-Charged` headers.
2. **Set a client timeout of at least 60 seconds.** The first request after a quiet period can take 15 to 35 seconds while a GPU starts.
3. **Check your error handling.** A wrong key returns `403 auth_failed`, an empty balance `402 insufficient_credits`, too many requests `429` with `Retry-After`, as before.
4. **Check the gaps.** 3D and car shadows return `400 unsupported_shadow_type`; automatic type detection and `/improve` are not available. Everything else is in [differences](https://cutmatte.com/docs/#differences).
5. **Run the compatibility scripts if you use a client library.** Our [public scripts](https://github.com/vlad-grigoryan/remove-bg-compat-tests) run remove.bg's npm and PyPI clients, its command-line tool and its own samples against any compatible API and print `PASS` or `FAIL` for each check.

## Examples

The cURL, Node.js, Python, PHP and Ruby examples are remove.bg's own samples with the address changed, and we run them against Cutmatte. The C# and Java examples are ours; we ran them against Cutmatte on 1 December 2026. The others say when they were not run.

### cURL

```
curl -H "X-Api-Key: YOUR_KEY" \
     -F "image_file=@/path/to/photo.jpg" \
     -F "size=auto" \
     -f https://api.cutmatte.com/v1.0/removebg -o no-bg.png
```

### Node.js

```
import fs from "node:fs";

const formData = new FormData();
formData.append("size", "auto");
formData.append("image_file", await fs.openAsBlob("/path/to/photo.jpg"));

const response = await fetch("https://api.cutmatte.com/v1.0/removebg", {
  method: "POST",
  headers: { "X-Api-Key": "YOUR_KEY" },
  body: formData,
});
if (!response.ok) throw new Error(`${response.status}: ${await response.text()}`);
fs.writeFileSync("no-bg.png", Buffer.from(await response.arrayBuffer()));
```

### Python

```
import requests

response = requests.post(
    "https://api.cutmatte.com/v1.0/removebg",
    files={"image_file": open("/path/to/photo.jpg", "rb")},
    data={"size": "auto"},
    headers={"X-Api-Key": "YOUR_KEY"},
)
if response.status_code == requests.codes.ok:
    with open("no-bg.png", "wb") as out:
        out.write(response.content)
else:
    print("Error:", response.status_code, response.text)
```

### PHP

```
<?php
$ch = curl_init("https://api.cutmatte.com/v1.0/removebg");
curl_setopt_array($ch, [
    CURLOPT_HTTPHEADER => ["X-Api-Key: YOUR_KEY"],
    CURLOPT_POSTFIELDS => ["image_file" => new CURLFile("/path/to/photo.jpg"), "size" => "auto"],
    CURLOPT_RETURNTRANSFER => true,
]);
$result = curl_exec($ch);
if (curl_getinfo($ch, CURLINFO_HTTP_CODE) === 200) {
    file_put_contents("no-bg.png", $result);
} else {
    echo "Error: " . $result;
}
```

### Ruby

```
require "net/http"

uri = URI("https://api.cutmatte.com/v1.0/removebg")
req = Net::HTTP::Post.new(uri, "X-Api-Key" => "YOUR_KEY")
req.set_form([["image_file", File.open("/path/to/photo.jpg")], ["size", "auto"]], "multipart/form-data")
res = Net::HTTP.start(uri.hostname, uri.port, use_ssl: true) { |http| http.request(req) }
if res.is_a?(Net::HTTPSuccess)
  File.binwrite("no-bg.png", res.body)
else
  puts "Error: #{res.body}"
end
```

### C# (.NET 6 or later)

```
using var client = new HttpClient { Timeout = TimeSpan.FromSeconds(60) };
client.DefaultRequestHeaders.Add("X-Api-Key", "YOUR_KEY");

using var form = new MultipartFormDataContent();
form.Add(new ByteArrayContent(File.ReadAllBytes("/path/to/photo.jpg")), "image_file", "photo.jpg");
form.Add(new StringContent("auto"), "size");

var response = await client.PostAsync("https://api.cutmatte.com/v1.0/removebg", form);
if (response.IsSuccessStatusCode)
    File.WriteAllBytes("no-bg.png", await response.Content.ReadAsByteArrayAsync());
else
    Console.WriteLine($"Error: {(int)response.StatusCode} {await response.Content.ReadAsStringAsync()}");
```

### Java 11 or later

```
import java.io.ByteArrayOutputStream;
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
import java.nio.file.Files;
import java.nio.file.Path;
import java.time.Duration;
import java.util.UUID;

public class RemoveBg {
    public static void main(String[] args) throws Exception {
        String boundary = UUID.randomUUID().toString();
        ByteArrayOutputStream body = new ByteArrayOutputStream();
        body.write(("--" + boundary + "\r\nContent-Disposition: form-data; name=\"size\"\r\n\r\nauto\r\n").getBytes());
        body.write(("--" + boundary + "\r\nContent-Disposition: form-data; name=\"image_file\"; filename=\"photo.jpg\"\r\n"
                + "Content-Type: image/jpeg\r\n\r\n").getBytes());
        body.write(Files.readAllBytes(Path.of("/path/to/photo.jpg")));
        body.write(("\r\n--" + boundary + "--\r\n").getBytes());

        HttpRequest request = HttpRequest.newBuilder(URI.create("https://api.cutmatte.com/v1.0/removebg"))
                .timeout(Duration.ofSeconds(60))
                .header("X-Api-Key", "YOUR_KEY")
                .header("Content-Type", "multipart/form-data; boundary=" + boundary)
                .POST(HttpRequest.BodyPublishers.ofByteArray(body.toByteArray()))
                .build();
        HttpResponse<byte[]> response = HttpClient.newHttpClient().send(request, HttpResponse.BodyHandlers.ofByteArray());
        if (response.statusCode() == 200) {
            Files.write(Path.of("no-bg.png"), response.body());
        } else {
            System.out.println("Error: " + response.statusCode() + " " + new String(response.body()));
        }
    }
}
```

### axios

```
import axios from "axios";
import FormData from "form-data";
import fs from "node:fs";

const form = new FormData();
form.append("size", "auto");
form.append("image_file", fs.createReadStream("/path/to/photo.jpg"));

const response = await axios.post("https://api.cutmatte.com/v1.0/removebg", form, {
  headers: { ...form.getHeaders(), "X-Api-Key": "YOUR_KEY" },
  responseType: "arraybuffer",
  timeout: 60000,
});
fs.writeFileSync("no-bg.png", response.data);
```

axios sends `Accept: application/json, text/plain, */*` by default. Cutmatte answers that with the image, as code written for remove.bg expects. Send `Accept: application/json` alone to get JSON.

### Laravel: `mtownsend/remove-bg`

```
use Mtownsend\RemoveBg\RemoveBg;

$removebg = new RemoveBg('YOUR_KEY');
$removebg->endpoint = 'https://api.cutmatte.com/v1.0/removebg';
$removebg->file('photo.jpg')->save('no-bg.png');
```

`$endpoint` is a public property of the package. `account()` builds its address from it. We did not run this example.

### n8n

In an **HTTP Request** node, change the URL from `https://api.remove.bg/v1.0/removebg` to `https://api.cutmatte.com/v1.0/removebg` and replace the value of the `X-Api-Key` header. Leave the method, the form fields and the response format as they are. Set the node's timeout to at least 60 seconds. We did not run n8n itself.

### Zapier and Make

remove.bg's own Zapier and Make apps called its API, so they stopped with it, and they have no address to change. Replace that step with the generic HTTP step: in Zapier, **Webhooks by Zapier** with a custom request; in Make, the **HTTP** module's "Make a request".

- Method `POST`, URL `https://api.cutmatte.com/v1.0/removebg`.
- Header `X-Api-Key` with your Cutmatte key.
- Body: form fields `image_url` (a public link to the photo, often available from the previous step) and `size`, for example `auto`. In Make you can also send the file itself as `image_file` in a multipart body.
- Timeout 60 seconds or more, and stop the flow when the status is not 200: some HTTP steps report success whatever the API answers.

We did not run these in Zapier or Make.

### WordPress plugins with a remove.bg key field

Most WordPress plugins send requests through WordPress's own HTTP functions. This must-use plugin sends every request for `api.remove.bg` to `api.cutmatte.com`, so the plugin itself stays as it is. Save it as `wp-content/mu-plugins/cutmatte.php` and put your Cutmatte key in the plugin's remove.bg key field.

```
<?php
/*
 * Plugin Name: Send remove.bg API calls to Cutmatte
 * Description: Sends every request a plugin makes to api.remove.bg to api.cutmatte.com instead.
 */
add_filter('pre_http_request', function ($response, $args, $url) {
    $old = 'https://api.remove.bg/';
    if (strpos($url, $old) !== 0) {
        return $response;
    }
    $args['timeout'] = max(60, (int) ($args['timeout'] ?? 5));
    return wp_remote_request('https://api.cutmatte.com/' . substr($url, strlen($old)), $args);
}, 10, 3);
```

Plugins that call the API from the visitor's browser, or with their own HTTP client, are not covered. We checked the PHP syntax but did not run it inside WordPress.

## Libraries and tools

### npm `remove.bg`

Version 1.3.0 has the address built in. Change it in one line after installing (repeat after reinstalling, or save it with `patch-package`):

```
sed -i.bak 's#https://api.remove.bg#https://api.cutmatte.com#' node_modules/remove.bg/dist/index.js
```

All three functions (`removeBackgroundFromImageFile`, `...Url`, `...Base64`), the result fields and the error arrays work unchanged. Or drop the package and use the Node.js example above.

### PyPI `removebg`

```
from removebg import RemoveBg
from removebg import removebg as removebg_module

removebg_module.API_ENDPOINT = "https://api.cutmatte.com/v1.0/removebg"
rmbg = RemoveBg("YOUR_KEY", "error.log")
rmbg.remove_background_from_img_file("photo.jpg")
```

### remove.bg command-line tool

In `lib/functions.js` of [remove-bg-cli](https://github.com/remove-bg/remove-bg-cli), replace `https://api.remove.bg/v1.0/removebg` with `https://api.cutmatte.com/v1.0/removebg`. The tool downloads ZIP results and joins them into PNG; that works with Cutmatte, background colours and images included.

### Ruby gem `remove_bg`

The gem reads its address from `RemoveBg::Api::URL` each time it connects ([source](https://github.com/remove-bg/ruby/blob/main/lib/remove_bg/http_connection.rb)), so replace the constant once at startup:

```
RemoveBg::Api.send(:remove_const, :URL)
RemoveBg::Api.const_set(:URL, "https://api.cutmatte.com")
RemoveBg.configure { |config| config.api_key = ENV.fetch("CUTMATTE_API_KEY") }
```

We read the gem's source but did not run the gem.

### .NET libraries that take an `HttpClient`

If a .NET wrapper lets you pass your own `HttpClient`, give it one with this handler. It sends requests for `api.remove.bg` to `api.cutmatte.com` and leaves everything else alone. We ran it against Cutmatte on 1 December 2026.

```
class SwitchToCutmatte : DelegatingHandler
{
    protected override Task<HttpResponseMessage> SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)
    {
        if (request.RequestUri is { Host: "api.remove.bg" } uri)
            request.RequestUri = new UriBuilder(uri) { Host = "api.cutmatte.com" }.Uri;
        return base.SendAsync(request, cancellationToken);
    }
}

var client = new HttpClient(new SwitchToCutmatte { InnerHandler = new HttpClientHandler() })
{
    Timeout = TimeSpan.FromSeconds(60)
};
```

### What we test

We run the npm package `remove.bg` 1.3.0, the PyPI package `removebg` 0.4, remove.bg's command-line tool and the cURL, Node.js and Python samples from remove.bg's API page against Cutmatte: 35 of 35 checks pass (24 November 2026). The checks cover the file, URL and base64 methods, sizes, formats including ZIP, background colours and images, channels, options and error responses; the scripts are [public](https://github.com/vlad-grigoryan/remove-bg-compat-tests). Using another client? Write to [support@cutmatte.com](mailto:support@cutmatte.com) and we will test it.

## Every remove.bg parameter on Cutmatte

| remove.bg | On Cutmatte |
|---|---|
| `image_file`, `image_file_b64`, `image_url` | Same |
| `size`: preview, small, regular, medium, hd, full, 4k, 50MP, auto | Same |
| `format`: auto, png, jpg, webp, zip | Same |
| `channels`, `roi` | Same |
| `bg_color`, `bg_image_url`, `bg_image_file` | Same |
| `crop`, `crop_margin`, `scale`, `position` | Same |
| `shadow_type`, `shadow_opacity` | Drop shadow works; `3D` and `car` return `400 unsupported_shadow_type` |
| `add_shadow` | As on remove.bg: a car shadow for `type=car` (returns 400 here), nothing otherwise |
| `type`, `type_level` | Accepted and reported in `X-Type`; with `type=auto` the type is `other`, as there is no automatic detection |
| `semitransparency` | Accepted, no effect |
| Headers `X-Credits-Charged`, `X-Width`, `X-Height`, `X-Max-*`, `X-Foreground-*`, `X-Type`, `X-RateLimit-*` | Same |
| `GET /v1.0/account` | Same format; all credits are reported as `payg` |
| `POST /v1.0/improve` | `400 improvement_program_unavailable` |

Values, defaults and limits for each parameter are in the [documentation](https://cutmatte.com/docs/).

## Troubleshooting

| What you see | Why | Fix |
|---|---|---|
| `403 auth_failed` right after switching | The old remove.bg key is still sent, often from an environment variable | Send the Cutmatte key; check every place the key is set |
| Requests still go to `api.remove.bg` | A wrapper or plugin has the address built in | Change it as shown in [libraries and tools](https://cutmatte.com/migrate/#libraries) or [WordPress](https://cutmatte.com/migrate/#wordpress) |
| The first request times out | A GPU starts after a quiet period: 15 to 35 seconds | Client timeout of at least 60 seconds |
| `400 invalid_body` | `Content-Type: multipart/form-data` set by hand, without the boundary | Remove that header and let your HTTP library set it |
| A broken image file with axios | axios reads the body as text by default | `responseType: "arraybuffer"`, as in the [axios example](https://cutmatte.com/migrate/#axios) |
| `402 insufficient_credits` after a few dozen images | The 50 free full-size images are used up | Buy credits, or send `size=preview` while testing |
| `X-Type` is always `other` | Cutmatte has no automatic type detection | Pass `type` if your code relies on it |

Still stuck? Write to [support@cutmatte.com](mailto:support@cutmatte.com) with the `X-Request-Id` header of the failing response.

## Free credits for remove.bg users

Unused remove.bg credits expired when its API closed on 1 December 2026. Send a screenshot of your last remove.bg balance from your [Cutmatte dashboard](https://cutmatte.com/dashboard/) and get the same number of free Cutmatte credits, up to 1,000, once per account. We check each screenshot by hand. The offer runs until 31 December 2026.

## Things to check

- Search your code and configuration for `api.remove.bg`, including environment variables, CI secrets and no-code tools.
- The first request after a quiet period can take 15–35 seconds while a GPU starts. Use a client timeout of at least 60 seconds.
- 3D and car shadows are not available; requests for them return `400 unsupported_shadow_type`. Drop shadows work.

## Cutmatte and Leonardo.Ai compared

remove.bg names Leonardo.Ai as its successor. The facts about Leonardo below are from its [migration guide](https://docs.leonardo.ai/docs/migrate-from-the-removebg-api-to-leonardoai), read on 25 November 2026.

|  | Cutmatte | Leonardo.Ai |
|---|---|---|
| Code change | Address and key | New endpoint, new account and key, JSON request body |
| Image upload | multipart, JSON or form body | JSON only: image URL, base64 or an uploaded image |
| Response | The image itself, as remove.bg sent it, or JSON with base64 | JSON with an image URL or base64 |
| ZIP output | Yes | No |
| Price per image | $0.009 to $0.003, prepaid credits that do not expire | $0.1047 |
| Shadows | Drop shadow only; 3D and car return 400 | `shadow_type` and `shadow_opacity` carry over, see its guide |
| First request after a quiet period | 15 to 35 s | Not stated |

## Questions

### Is the response format the same?

Yes: the image itself by default, JSON with `result_b64` when you send `Accept: application/json`, the same headers and the same error JSON. Cutmatte adds `X-Credits-Remaining` and `X-Request-Id`, which remove.bg clients ignore.

### How do I test before I switch?

A new account gets 50 full-size images once and 50 previews every month. Run your usual images, then run the [compatibility scripts](https://github.com/vlad-grigoryan/remove-bg-compat-tests) if you use a wrapper.

### Is a failed call charged?

No. Neither are images where no subject is found.

### Can I call it from a browser?

Yes, as with remove.bg: `/v1.0/*` allows cross-origin requests. Anyone can read a key placed in a public page, so for new code call the API from your server.

### What if Cutmatte closes?

Our [terms](https://cutmatte.com/terms.html) say we refund the unused part of your credits if we discontinue the service, and that we announce changes by email. Your code stays remove.bg-compatible, so moving again is the same URL change. [Get a free API key](https://cutmatte.com/dashboard/)[Read the docs](https://cutmatte.com/docs/)
