Change Clothes AI API Documentation
2025-05-28
Posted byChange 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.
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 Name | Required | Description |
---|---|---|
content-type | Yes | Must be multipart/form-data |
authorization | Yes | Must be Bearer ${SECRET_KEY} ${SECRET_KEY} is your API key. |
Request Body FormData Parameters
Parameter | Type | Required | Description |
---|---|---|---|
modelImg | string or file | Yes | Model 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. |
garmentImg | string or file | Yes | Garment Image. It accepts three input formats same to modelImg . |
category | string | Yes | Garment category, enums: upper_body, lower_body, dresses |
garmentDesc | string | No | Optional Garment Desc in English |
Response JSON Format
Field | Type | Description |
---|---|---|
code | number | Response status code. 200 for success. |
msg | string | Response message, provides additional information |
data | object | Response data object, present when code is 200 |
data.resultImgUrl | string | Url of result image |
data.maskImgUrl | string | Url of model image with inpaint mask |
data.cacheHit | boolean | true if hit cache of preset model and garment image. **Only cached for preset-models and preset-garments ** |
Response Codes
Code | Message | Description |
---|---|---|
200 | OK | Request successful |
500 | SERVER_ERROR | Internal server error |
10001 | NOT_LOGIN | User not authenticated |
10002 | USER_NOT_EXIST | User does not exist |
10003 | INSUFFICIENT_CREDITS | Insufficient credits |
10004 | INVALID_PARAM | Invalid parameters |
10005 | HARMFUL_CONTENT | Harmful content detected |
10006 | INSUFFICIENT_TRAIL_COUNT | Trial usage limit exceeded |
20001 | TRY_ON_EXCEPTION | Processing error |
30001 | INVALID_API_KEY | Invalid API key |
30002 | INVALID_SIGNATURE | Invalid 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 Name | Required | Description |
---|---|---|
content-type | Yes | Must be multipart/form-data |
authorization | Yes | Must be Bearer ${SECRET_KEY} ${SECRET_KEY} is your API key. |
Request Body FormData Parameters
Parameter | Type | Required | Description |
---|---|---|---|
modelImg | string or file | Yes | Model 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. |
prompt | string | Yes | Change clothes prompt in English. e.g. Help the model change into a blue striped shirt. |
seed | string | No | Seed to begin AI process, range from 0 to 2147483647. Optional param, and it will be override if randomize_seed is true. |
randomize_seed | string | No | Generate random seed, enums: true, false. |
guidance_scale | string | No | Sets 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_steps | string | No | Modify 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
Field | Type | Description |
---|---|---|
code | number | Response status code. 200 for success. |
msg | string | Response message, provides additional information |
data | object | Response data object, present when code is 200 |
data.resultImgUrl | string | Url of result image |
data.seed | number | Seed to generate image |
Response Codes
Code | Message | Description |
---|---|---|
200 | OK | Request successful |
500 | SERVER_ERROR | Internal server error |
10001 | NOT_LOGIN | User not authenticated |
10002 | USER_NOT_EXIST | User does not exist |
10003 | INSUFFICIENT_CREDITS | Insufficient credits |
10004 | INVALID_PARAM | Invalid parameters |
10005 | HARMFUL_CONTENT | Harmful content detected |
10006 | INSUFFICIENT_TRAIL_COUNT | Trial usage limit exceeded |
20001 | TRY_ON_EXCEPTION | Processing error |
30001 | INVALID_API_KEY | Invalid API key |
30002 | INVALID_SIGNATURE | Invalid 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.
Help & Support
If you have any questions or need assistance, please don't hesitate to contact our support team.
Email: [email protected]