Cloth Swap

Cloth Swap

Overview

The Cloth Swap AI tool is a powerful technology that lets you virtually try on different clothes in your photos. Simply upload your photo and an image of the clothing item you want to wear, and our AI will seamlessly blend them together, making it look like you're actually wearing that piece of clothing. This is perfect for:

  • Trying out new outfits before buying them online
  • Visualizing how different styles would look on you
  • Creating fashion content for social media
  • Virtual fitting rooms for e-commerce

The tool uses advanced AI technology to ensure the clothing looks natural and properly fitted to your body position and shape.

API Reference

  • URL: https://api.maxstudio.ai/cloth-swap
  • Method: POST

API Parameters

NameTypeRequiredDescription
imagestringyesBase64 encoded person image
clothstringyesDesired cloth in Base64 image

⚠️ Important: When sending the base64 image, do not include the prefix (e.g., 'data:image/jpeg;base64,'). Send only the raw base64 string.

Headers

NameTypeRequiredDescription
x-api-keystringyesYour API key obtained from the MaxStudio APIs Dashboard (opens in a new tab). Generate this key by logging into your account and navigating to the API Keys section.

Code Examples

// TypeScript implementation
interface Params {
image: string;
cloth: string;
}
async function ClothSwap(params: Params): Promise<any> {
try {
const response = await fetch('https://api.maxstudio.ai/cloth-swap', {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify({
image: params.image,
cloth: params.cloth
})
});
const jobId = await response.json();
return jobId;
} catch (error) {
console.error('Error:', error);
throw error;
}
}

Success Response

{
  "jobId": "<job_id>"
}

Error Response Examples

// Rate Limit Error
{
  "status": 429,
  "error": "Rate limit exceeded. Please try again later."
}
// Insufficient Credits
{
  "status": 402,
  "error": "Insufficient credits. Please Buy credits."
}
// Invalid Input
{
  "status": 400,
  "error": "Image size must be less than 5MB"
}

Get Job Status

Headers

NameTypeRequiredDescription
x-api-keystringyesYour API key obtained from the MaxStudio APIs Dashboard (opens in a new tab). Generate this key by logging into your account and navigating to the API Keys section.

To check the status of your job, use the following examples:

// TypeScript implementation
async function getJobStatus(jobId: string): Promise<any> {
const url = `https://api.maxstudio.ai/cloth-swap/${jobId}`;
try {
const response = await axios.get(url);
const jobId = await response.json();
return jobId;
} catch (error) {
console.error('Error:', error);
throw error;
}
}

Job Status Reference

StatusDescription
creatingJob is being initialized
pendingJob is in processing queue
runningJob is actively processing
completedProcessing finished successfully
failedProcessing encountered an error
not-foundInvalid or expired job ID

Output

{
  "status": "<status>",  // One of the status values from the table above
  "result": {
    "result": "<result>"   // Base64 encoded image data when status is 'completed'
  }
}