Skip to main content

Generate Background Image

This API endpoint allows you to replace the background of an image with an AI-generated background based on a provided text prompt.

How it works

  1. Provide Image URL: Submit the URL of the image whose background you want to replace.
  2. Craft Your Prompt: Describe the desired background in English using a detailed prompt. Be specific about the elements, textures, colors, and style you want in the new background.
  3. Optional: Use Negative Prompts: You can refine the results by adding negative prompts, specifying elements you don't want to see in the generated background.

Basic Usage

curl --location 'https://dev-api.katalis.ai/service/v1/generate-image' \
--header 'Content-Type: application/json' \
--data '{
"image_urls": [
"https://image.url.com",
"https://image2.url.com"
],
"background": {
"prompt": "transparent",
"negative_prompt": ""
},
"result_number": 2
}'

Explanation:

  • "image_url": The URL of the image you want to modify.
  • "background": An object containing the following:
  • "prompt": A detailed text description of the desired background.
  • "negative_prompt": (Optional) Elements you want to exclude from the generated background.

API Response Example

{
"message": "Success",
"data": [
{
"original_image_url": "https://image.url.com",
"generated_image_urls": [
"https://storage.googleapis.com/katalis-ai/image/generated/1/1713944425-2290.png",
"https://storage.googleapis.com/katalis-ai/image/generated/1/1713944425-2291.png"
]
},
{
"original_image_url": "https://image2.url.com",
"generated_image_urls": [
"https://storage.googleapis.com/katalis-ai/image/generated/1/1713944425-2292.png",
"https://storage.googleapis.com/katalis-ai/image/generated/1/1713944425-2293.png"
]
}
]
}

Response Fields:

  • "message": Indicates the status of the request (e.g., "Success").
  • "data": Contains the generated image URL:
  • "img_url": A URL pointing to the newly generated image with the replaced background.

Before & After Example

Original Image:

original

Prompt: "a professional photo of an object on a table made of dark Wood, dark wood countertop, hd dark Wood wallpaper, award winning photography"

Negative Prompt: "yellow wall"

Generated Image:

generated