In-Depth Tutorial

The Generate Background API is now considered legacy.

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

The Photoroom Generate Background API allows you to easily create new backgrounds for your images.

This API works by using Generative AI to dynamically create new backgrounds, that match the subject of the original picture.

Here's how a call to the API looks like:

As you can see, you need to provide 3 arguments:

  • apiKey: your personal PhotoRoom API key

  • prompt: the description of the next background

  • imageUrl: the URL of the image you want to use

The API has been designed so that it is very easy to integrate into an existing website.

Below you will find more details on the values you need to pass for the arguments apiKey and prompt, along with detailed steps to make your first call

Get an API key

The first thing you need to do is get your API key. Here are the steps you'll need to follow:

pageHow can I get my API key?

Write the prompt

The prompt argument is a textual description of what the new background should look like.

It can feel challenging to write a good prompt.

However, we have a way to provide you with good examples:

  1. Go to the Photoroom Web App and upload an image for which you'd like to generate a new background

  2. Open “Instant Backgrounds” on the left panel

  • The first 2 results are backgrounds that have been generated specifically for your image, and the prompt is visible below the tile!

  • And if you tap on any of the “scenes”, you'll see the full prompt on top. You can even edit it to see how variations of the prompt would impact the generated background!

If you want a result that looks similar to the 4 options generated by the apps, make sure that, in addition to the prompt, you also use the same seed than the apps.

Generate your background

Now that you have your apiKey and your prompt, you're ready to generate your background!

We recommend you check out our API Reference, where you'll find code samples to implement the API call in several programming languages.

Additional Parameters

In addition to the prompt, the Generate Background API provides two optional parameters that give you additional control over how the new background will be generated: negativePrompt and seed.


The negativePrompt allows you to refine your generated background by specifying elements our AI won’t include in the final image.

For example, if you'd like a wedding-themed background without any flowers in view, consider a negative prompt such as "flowers":


If you make several calls to the Generate Background API with the same image and the same prompt, you will notice that it will generate a different background each time.

This is great when you're looking for inspiration, but it might become an issue when you need consistency.

In order to reduce the randomness, you can set a fixed value for the seed that the API's random generator will use. The value of the seed can be any positive integer.

When you provide a fixed seed, the API should produce similar-looking backgrounds for the same prompt.

The iOS, Android and Web versions of PhotoRoom always use the same seeds for the first 4 generated background options they present to the user.

You can use the same values if you want to have results similar to that of the PhotoRoom apps: 117879368, 55994449, 48672244 and 65080068.


We'd love to learn about your use case for the API, bugs, and any feature requests you might have!

Feel free to join our Slack Community and ask our engineers!

Last updated