Can I send my image in Base64 format?

A: Yes, sending your image in Base64 format is possible for the Remove Background API.

Here’s are some sample codes in JavaScript and Python:

const removeBackground = async (base64Image) => {
  const options = {
    method: "POST",
    headers: {
      "x-api-key": YOUR_API_KEY,
      "Content-Type": "application/json",
      Accept: "application/json",
    },
    body: JSON.stringify({
      image_file_b64: base64Image.split(",")[1],
    }),
  };

  fetch("https://sdk.photoroom.com/v1/segment", options)
    .then((response) => response.json())
    .then((response) => {
      console.log(response);
    })
    .catch((err) => console.error(err));
};

type or paste code here