👩‍💻Snippets

Customizable code snippets for our endpoints

Find more in the Postman Workspace

Python - Create Render (from Image URL)

import requests
import json

url = "https://api.virtualstagingai.app/v1/render/create"
VSAI_API_KEY = "..."

payload = json.dumps({
  "image_url": "https://firebasestorage.googleapis.com/v0/b/furniture-ai.appspot.com/o/users%2FX5AvCT5OUcaflJkXefQofEkDcW42%2Ffootage%2F6aec0ecf-8a52-4b49-a81d-031e91ce33e5-0001-022_181_HDR_4143.jpg?alt=media&token=28136001-ad8e-4c97-afe7-5f5b68054a1c",
  "room_type": "bed",
  "style": "modern",
  "wait_for_completion": False
})
headers = {
  'Authorization': 'Api-key ' + VSAI_API_KEY,
  'Content-Type': 'application/json'
}

response = requests.request("POST", url, headers=headers, data=payload)

print(response.text)

Python - Create Render (from file, using multipart form-data)


import requests
import json
from urllib.parse import urlencode, urljoin

url = "https://api.virtualstagingai.app/v1/render/create"
VSAI_API_KEY = "..."

def add_url_params(url, params):
    return url + '?' + urlencode(params).lower() if params else url

image_path = "/path/to/your/image.jpg"  # replace with your image's path

payload = {
  "room_type": "bed",
  "style": "modern",
  "wait_for_completion": False
}

headers = {
  'Authorization': 'Api-key ' + VSAI_API_KEY,
}

# we need to add payload as url params if we're using request body for the image
url = add_url_params(url, payload)

with open(image_path, 'rb') as image_file:
    files = {
        # important: 'file' has to be the key
        'file': (image_path, image_file),
    }
    response = requests.post(url, headers=headers, data=payload, files=files)

print(response.text)

Node JS w/ Axios - Create Render

const axios = require('axios');
const VSAI_API_KEY = "...";

const image_url = "...";
let data = JSON.stringify({
  "image_url": image_url,
  "room_type": "bed",
  "style": "modern",
  "wait_for_completion": false
});

const url = 'https://api.virtualstagingai.app/v1/render/create';
let config = {
  method: 'post',
  maxBodyLength: Infinity,
  url,
  headers: { 
    'Authorization': 'Api-key ' + VSAI_API_KEY, 
    'Content-Type': 'application/json'
  },
  data : data
};

axios.request(config)
.then((response) => {
  console.log(JSON.stringify(response.data));
})
.catch((error) => {
  console.log(error);
});

Last updated