How do I make my first call?

The Generate Background API is now considered legacy.

We strongly recommend that you use the Image Editing API v2 instead.

To call the Generate Background API and replace the background of an image with a new AI-generated background, you can run the following code in your terminal:

curl --request POST \
  --url https://beta-sdk.photoroom.com/v1/instant-backgrounds \
  --header 'Accept: image/png, application/json' \
  --header 'Content-Type: multipart/form-data' \
  --header 'x-api-key: YOUR_API_KEY' \
  --form imageFile=@/absolute/path/to/image.jpg \
  --form prompt="on a beautiful wooden table" \
  --output photoroom-result.png

If you don't have an apiKey, here are the steps to create yours.

This will replace the background of your image with a new one that fits the description of having the subject "on a beautiful wooden table".

For more details on how the Generate Background API works, a detailed tutorial is available here.

Last updated