Back to Home

Change Clothes AI API Documentation

2025-05-28

Posted by

Change Clothes AI API Documentation

Introduction & Use Cases

Change Clothes AI API enables developers to easily apply virtual garments onto model images via a simple API call. It is ideal for e-commerce, virtual try-on, fashion styling, and content creation scenarios. Whether you want to provide users with an online try-on experience or help content creators generate diverse outfit images, this API can greatly improve efficiency and user experience.

Common Use Cases

  • E-commerce platforms offering virtual try-on to boost conversion rates
  • Fashion styling apps generating outfit previews
  • Content creators batch-generating clothing combination images
  • Fashion designers previewing new garment designs on models
  • AI avatars or virtual characters changing outfits

API Keys

To use our API, you'll need to obtain API credentials . You can manage your API keys in the dashboard.

Manage API Keys →

API 1 : Change Clothes with Clothes Image

To use this api, you will need to provide model images and clothing images. If you don't have an image of the garment, or would like to describe the clothing through text, see the next api.

API Endpoint

POST https://changeclothesai.online/api/openapi/change-clothes-ai

Integration Guide

Request Headers

Header NameRequiredDescription
content-typeYesMust be multipart/form-data
authorizationYesMust be Bearer ${SECRET_KEY}
${SECRET_KEY} is your API key.

Request Body FormData Parameters

ParameterTypeRequiredDescription
modelImgstring or fileYesModel image. It accepts three input formats:
1. Model Image URL, starting with http:// or https://.
2. Base64 Encoded Image, following the format: data:image/jpeg;base64,/9j/4AAQSkZJR... (Note: other image types like PNG are also possible, adjust the mime-type accordingly)
3. File Object: A file object representing the model image.
garmentImgstring or fileYesGarment Image. It accepts three input formats same to modelImg .
categorystringYesGarment category, enums: upper_body, lower_body, dresses
garmentDescstringNoOptional Garment Desc in English

Response JSON Format

FieldTypeDescription
codenumberResponse status code. 200 for success.
msgstringResponse message, provides additional information
dataobjectResponse data object, present when code is 200
data.resultImgUrlstringUrl of result image
data.maskImgUrlstringUrl of model image with inpaint mask
data.cacheHitbooleantrue if hit cache of preset model and garment image.
**Only cached for preset-models and preset-garments **
Response Codes
CodeMessageDescription
200OKRequest successful
500SERVER_ERRORInternal server error
10001NOT_LOGINUser not authenticated
10002USER_NOT_EXISTUser does not exist
10003INSUFFICIENT_CREDITSInsufficient credits
10004INVALID_PARAMInvalid parameters
10005HARMFUL_CONTENTHarmful content detected
10006INSUFFICIENT_TRAIL_COUNTTrial usage limit exceeded
20001TRY_ON_EXCEPTIONProcessing error
30001INVALID_API_KEYInvalid API key
30002INVALID_SIGNATUREInvalid request signature
Example Response
{
    "code": 200,
    "data":
    {
        "resultImgUrl": "https://persistent.changeclothesai.online/change-clothes-ai/cache/1747493767397255851.webp",
        "maskImgUrl": "https://persistent.changeclothesai.online/change-clothes-ai/cache/1747493770543821630.webp",
        "cacheHit": true
    }
}

Code Examples

Curl Example With Image Url

curl --location 'https://changeclothesai.online/api/openapi/change-clothes-ai' \
--header 'Authorization: Bearer ${SECRET_KEY}' \
--form 'garmentImg="https://persistent.changeclothesai.online/change-clothes-ai/assets/examples/garment-tab/dresses/04-01.jpg"' \
--form 'category="dresses"' \
--form 'modelImg="https://persistent.changeclothesai.online/change-clothes-ai/assets/examples/person-tab/women/003.jpg"'

Curl Example With Local Image File

curl --location 'https://changeclothesai.online/api/openapi/change-clothes-ai' \
--header 'Authorization: Bearer ${SECRET_KEY}' \
--form 'garmentImg=@"/PATH/TO/YOUR/GARMENT/IMAGE.jpg"' \
--form 'category="dresses"' \
--form 'modelImg=@"/PATH/TO/YOUR/MODEL/IMAGE.png"'

Curl Example With Image Base64

curl --location 'https://changeclothesai.online/api/openapi/change-clothes-ai' \
--header 'Authorization: Bearer ${SECRET_KEY}' \
--form 'garmentImg="data:image/jpeg;base64,/9j……/9k="' \
--form 'category="dresses"' \
--form 'modelImg="data:image/jpeg;base64,/9j……/9k="'

Node.js Example

async function callChangeClothesApi() {
  const apiKey = 'YOUR_API_KEY'; // Replace with your actual API key

  const formData = new FormData();
  formData.append('modelImg', ...); // Support url, image file, image base64 encode
  formData.append('garmentImg', ...); // Support url, image file, image base64 encode
  formData.append('category', ...); // upper_body, lower_body, dresses
  if (...) { // judge garmentDesc not empty
    formData.append('garmentDesc', ...);
  }

  const apiEndpoint = 'https://changeclothesai.online/api/openapi/change-clothes-ai';
  try {
    const response = await fetch(apiEndpoint, {
      method: 'POST',
      headers: {
        'Authorization': `Bearer ${apiKey}`,
      },
      body: formData,
    });

    if (!response.ok) {
      const errorData = await response.json();
      throw new Error(`HTTP error ${response.status}: ${errorData.msg || 'Unknown error'}`);
    }

    const data = await response.json();
    return { resultImgUrl: data.data.resultImgUrl, maskImgUrl: data.data.maskImgUrl, error: null };

  } catch (error) {
    console.error('Error changing clothes:', error);
    return { resultImgUrl: null, maskImgUrl: null, error: error.message };
  }
}

Python Example


import requests
import base64

async def call_change_clothes_api():
    api_key = 'YOUR_API_KEY'  # Replace with your actual API key

    form_data = {
        'modelImg': 'data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAAAQABAAD...',  # Example base64 image. Replace with your actual image data. Supports url, file, and base64.
        'garmentImg': 'https://example.com/garment.png', # Example url. Supports url, file, and base64.
        'category': 'upper_body',  # upper_body, lower_body, dresses
        'garmentDesc': 'A beautiful red dress' # Example description. Remove this line if garmentDesc is empty
    }

    api_endpoint = 'https://changeclothesai.online/api/openapi/change-clothes-ai'
    try:
        headers = {
            'Authorization': f'Bearer {api_key}',
        }

        response = requests.post(api_endpoint, files=form_data, headers=headers) # Use files= for multipart/form-data
        response.raise_for_status()  # Raise an exception for bad status codes (4xx or 5xx)

        data = response.json()
        return {'resultImgUrl': data.get('data', {}).get('resultImgUrl'), 'maskImgUrl': data.get('data', {}).get('maskImgUrl'), 'error': None}

    except requests.exceptions.RequestException as e:
        print(f'Error changing clothes: {e}')
        return {'resultImgUrl': None, 'maskImgUrl': None, 'error': str(e)}

API 2 : Change Clothes by Prompt

To use this api, you need to provide a model image and clothing description PROMPT.

API Endpoint

POST https://changeclothesai.online/api/openapi/change-clothes-by-prompt

Integration Guide

Request Headers

Header NameRequiredDescription
content-typeYesMust be multipart/form-data
authorizationYesMust be Bearer ${SECRET_KEY}
${SECRET_KEY} is your API key.

Request Body FormData Parameters

ParameterTypeRequiredDescription
modelImgstring or fileYesModel image. It accepts three input formats:
1. Model Image URL, starting with http:// or https://.
2. Base64 Encoded Image, following the format: data:image/jpeg;base64,/9j/4AAQSkZJR... (Note: other image types like PNG are also possible, adjust the mime-type accordingly)
3. File Object: A file object representing the model image.
promptstringYesChange clothes prompt in English.
e.g. Help the model change into a blue striped shirt.
seedstringNoSeed to begin AI process, range from 0 to 2147483647. Optional param, and it will be override if randomize_seed is true.
randomize_seedstringNoGenerate random seed, enums: true, false.
guidance_scalestringNoSets the influence weight of prompt, numeric type, range is 1-100, the larger the weight the higher. Optional, defaults to 50. only recommended to adjust this parameter if necessary
num_inference_stepsstringNoModify the number of iterations of the image, numeric type, range 1-50. optional, default value 28, only recommended to adjust this parameter if necessary

Response JSON Format

FieldTypeDescription
codenumberResponse status code. 200 for success.
msgstringResponse message, provides additional information
dataobjectResponse data object, present when code is 200
data.resultImgUrlstringUrl of result image
data.seednumberSeed to generate image
Response Codes
CodeMessageDescription
200OKRequest successful
500SERVER_ERRORInternal server error
10001NOT_LOGINUser not authenticated
10002USER_NOT_EXISTUser does not exist
10003INSUFFICIENT_CREDITSInsufficient credits
10004INVALID_PARAMInvalid parameters
10005HARMFUL_CONTENTHarmful content detected
10006INSUFFICIENT_TRAIL_COUNTTrial usage limit exceeded
20001TRY_ON_EXCEPTIONProcessing error
30001INVALID_API_KEYInvalid API key
30002INVALID_SIGNATUREInvalid request signature
Example Response
{
    "code": 200,
    "data":
    {
        "resultImgUrl": "https://r2.changeclothesai.online/1748486113268661990.webp",
        "seed": 627512067
    }
}

Code Examples

Curl Example With Image Url

curl --location 'https://changeclothesai.online/api/openapi/change-clothes-by-prompt' \
--header 'Authorization: Bearer ${SECRET_KEY}' \
--form 'modelImg="https://persistent.changeclothesai.online/change-clothes-ai/assets/examples/person-tab/women/003.jpg"' \
--form 'prompt="Help the model change into a blue striped shirt."'

Curl Example With Local Image File

# curl with image url
curl --location 'https://changeclothesai.online/api/openapi/change-clothes-by-prompt' \
--header 'Authorization: Bearer ${SECRET_KEY}' \
--form 'modelImg=@"/PATH/TO/YOUR/MODEL/IMAGE.png"' \
--form 'prompt="Help the model change into a blue striped shirt."'

Curl Example With Image Base64

# curl with image url
curl --location 'https://changeclothesai.online/api/openapi/change-clothes-by-prompt' \
--header 'Authorization: Bearer ${SECRET_KEY}' \
--form 'modelImg="data:image/jpeg;base64,/9j……/9k="' \
--form 'prompt="Help the model change into a blue striped shirt."'

Node.js Example

async function callChangeClothesApi() {
  const apiKey = 'YOUR_API_KEY'; // Replace with your actual API key

  const formData = new FormData();
  formData.append('modelImg', ...); // Support url, image file, image base64 encode
  formData.append('prompt', 'Help the model change into a blue striped shirt.');
  

  const apiEndpoint = 'https://changeclothesai.online/api/openapi/change-clothes-by-prompt';
  try {
    const response = await fetch(apiEndpoint, {
      method: 'POST',
      headers: {
        'Authorization': `Bearer ${apiKey}`,
      },
      body: formData,
    });

    if (!response.ok) {
      const errorData = await response.json();
      throw new Error(`HTTP error ${response.status}: ${errorData.msg || 'Unknown error'}`);
    }

    const data = await response.json();
    return { resultImgUrl: data.data.resultImgUrl, seed: data.data.seed };

  } catch (error) {
    console.error('Error changing clothes:', error);
    return { resultImgUrl: null, maskImgUrl: null, error: error.message };
  }
}

Python Example


import requests
import base64

async def call_change_clothes_api():
    api_key = 'YOUR_API_KEY'  # Replace with your actual API key

    form_data = {
        'modelImg': 'data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAAAQABAAD...',  # Example base64 image. Replace with your actual image data. Supports url, file, and base64.
        'prompt': 'Help the model change into a blue striped shirt.'
    }

    api_endpoint = 'https://changeclothesai.online/api/openapi/change-clothes-by-prompt'
    try:
        headers = {
            'Authorization': f'Bearer {api_key}',
        }

        response = requests.post(api_endpoint, files=form_data, headers=headers) # Use files= for multipart/form-data
        response.raise_for_status()  # Raise an exception for bad status codes (4xx or 5xx)

        data = response.json()
        return {'resultImgUrl': data.get('data', {}).get('resultImgUrl'), 'seed': data.get('data', {}).get('seed')}

    except requests.exceptions.RequestException as e:
        print(f'Error changing clothes: {e}')
        return {'resultImgUrl': None, 'seed': None, 'error': str(e)}

Pricing

API calls consume credits from your account. You can purchase credits on our pricing page.

View Pricing →

Help & Support

If you have any questions or need assistance, please don't hesitate to contact our support team.

Email: [email protected]