POST
javascript
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 const axios = require('axios'); const fs = require('fs'); const path = require('path'); async function toB64(imgPath) { const data = fs.readFileSync(path.resolve(imgPath)); return Buffer.from(data).toString('base64'); } const api_key = "YOUR API-KEY"; const url = "https://api.segmind.com/v1/furniture-staging"; const data = { "prompt": "photo of a white table with plant pot placed on an interior", "main_image": "toB64('https://i.ibb.co/z8pdz41/main-image.png')", "overlay_image": "toB64('https://i.ibb.co/bHhQFBq/overlay-image.png')", "main_image_mask": "toB64('https://i.ibb.co/GFxb3SX/main-image-mask.png')", "overlay_image_mask": "toB64('https://i.ibb.co/8cqzRHL/overlay-image-mask.png')", "steps": 25, "seed": 42424242, "guidance": 30, "image_format": "png", "image_quality": 95 }; (async function() { try { const response = await axios.post(url, data, { headers: { 'x-api-key': api_key } }); console.log(response.data); } catch (error) { console.error('Error:', error.response.data); } })();
RESPONSE
image/jpeg
HTTP Response Codes
200 - OKImage Generated
401 - UnauthorizedUser authentication failed
404 - Not FoundThe requested URL does not exist
405 - Method Not AllowedThe requested HTTP method is not allowed
406 - Not AcceptableNot enough credits
500 - Server ErrorServer had some issue with processing

Attributes


promptstr *

The main prompt describing the scene or subject


main_imageimage *

The URL of the main image


overlay_imageimage *

The URL of the overlay image


main_image_maskimage *

The URL of the main image mask


overlay_image_maskimage ( default: https://i.ibb.co/8cqzRHL/overlay-image-mask.png )

The URL of the overlay image mask


stepsint ( default: 25 )

The number of steps for image processing

min : 10,

max : 100


seedint ( default: 42424242 )

Random seed for reproducibility


guidanceint ( default: 30 )

Guidance scale for adjusting adherence to the prompt

min : 1,

max : 50


image_formatenum:dropdown ( default: png )

The output image format

Allowed values:


image_qualityint ( default: 95 )

The quality of the output image

min : 10,

max : 100

To keep track of your credit usage, you can inspect the response headers of each API call. The x-remaining-credits property will indicate the number of remaining credits in your account. Ensure you monitor this value to avoid any disruptions in your API usage.

Each parameter of the model controls a specific aspect of the furniture staging process. Here's a breakdown:

  • prompt:
    This describes the scene or subject you want to stage. Write a detailed description of how the staged furniture or design should look.

  • main_image:
    The primary image of the room or space where the furniture will be staged. Ensure the URL is accessible and points to a clear, high-quality image.

  • overlay_image:
    The secondary image containing the furniture or staging items to overlay on the main image. Provide the URL of the furniture/staging image.

  • main_image_mask:
    A mask for the main image. This defines areas to focus on for staging (e.g., walls, floors). If not provided, staging might be applied globally.

  • overlay_image_mask (optional):

    • If the furniture in the overlay image has a white background, the model will automatically create a mask for it.
    • If the overlay image is a lifestyle image or contains more than one furniture item, you should provide a custom mask.
  • steps:
    This determines the number of processing steps. Higher values lead to better quality but take longer.

  • seed:
    Sets a random seed for reproducibility. Change this if you want different variations of the same setup.

  • guidance:
    Controls how strictly the output adheres to the prompt. Higher values ensure the output matches your prompt but can reduce creativity.

  • image_format:
    Specifies the format of the output image. Options are usually png, jpeg, etc. Choose png for lossless quality.

  • image_quality:
    Sets the quality of the output image. Higher values produce better quality but larger file sizes.


Prepare Your Inputs

Make sure all inputs are ready:

  • Images:

    • Upload the main_image and overlay_image to a cloud service or use an accessible URL.
    • If masks are needed, ensure they match the size and format of their respective images.
  • Prompt:

    • Be specific about the furniture type, arrangement, and style (e.g., "Place a modern gray sofa").