Change Clothes AI API ドキュメント
2025-05-28
Posted byChange Clothes AI API ドキュメント
はじめに & ユースケース
Change Clothes AI APIは、開発者がモデル画像にバーチャル衣服を簡単に適用できるAPIです。Eコマース、バーチャル試着、ファッションスタイリング、コンテンツ制作などのシナリオに最適です。オンライン試着体験を提供したい場合や、コンテンツ制作者が多様なコーディネート画像を生成したい場合、このAPIは効率とユーザー体験を大幅に向上させます。
主なユースケース
- Eコマースプラットフォームでバーチャル試着を提供し、コンバージョン率を向上
- ファッションスタイリングアプリでコーディネートプレビューを生成
- コンテンツ制作者が衣服の組み合わせ画像を一括生成
- ファッションデザイナーが新しい衣服デザインをモデルでプレビュー
- AIアバターやバーチャルキャラクターの衣装チェンジ
APIキー
APIを利用するには、API認証情報が必要です。APIキーはダッシュボードで管理できます。
API 1 : 衣服画像で着せ替え
このAPIを利用するには、モデル画像と衣服画像を提供する必要があります。衣服画像がない場合や、テキストで衣服を説明したい場合は、次のAPIをご覧ください。
APIエンドポイント
POST https://changeclothesai.online/api/openapi/change-clothes-ai
統合ガイド
リクエストヘッダー
| ヘッダー名 | 必須 | 説明 |
|---|---|---|
| content-type | はい | multipart/form-data である必要があります |
| authorization | はい | Bearer $ である必要があります。 $ はあなたのAPIキーです。 |
リクエストボディ FormData パラメータ
| パラメータ | 型 | 必須 | 説明 |
|---|---|---|---|
| modelImg | string または file | はい | モデル画像。3つの入力形式をサポート: 1. モデル画像URL(http://またはhttps://で始まる) 2. Base64エンコード画像(例: data:image/jpeg;base64,/9j/4AAQSkZJR... 他の画像タイプも可、mime-typeを調整) 3. ファイルオブジェクト(画像ファイル) |
| garmentImg | string または file | はい | 衣服画像。modelImgと同じ3つの入力形式をサポート |
| category | string | はい | 衣服カテゴリ、enum: upper_body, lower_body, dresses |
| garmentDesc | string | いいえ | オプションの衣服説明(英語) |
レスポンスJSON形式
| フィールド | 型 | 説明 |
|---|---|---|
| code | number | レスポンスステータスコード。200は成功。 |
| msg | string | レスポンスメッセージ、追加情報を提供 |
| data | object | レスポンスデータオブジェクト。codeが200の時に存在 |
| data.resultImgUrl | string | 結果画像のURL |
| data.maskImgUrl | string | インペイントマスク付きモデル画像のURL |
| data.cacheHit | boolean | プリセットモデル・衣服画像の場合キャッシュヒット時true プリセットモデル・衣服のみキャッシュ |
レスポンスコード
| コード | メッセージ | 説明 |
|---|---|---|
| 200 | OK | リクエスト成功 |
| 500 | SERVER_ERROR | サーバー内部エラー |
| 10001 | NOT_LOGIN | ユーザー未認証 |
| 10002 | USER_NOT_EXIST | ユーザーが存在しない |
| 10003 | INSUFFICIENT_CREDITS | クレジット不足 |
| 10004 | INVALID_PARAM | パラメータ不正 |
| 10005 | HARMFUL_CONTENT | 有害なコンテンツ検出 |
| 10006 | INSUFFICIENT_TRAIL_COUNT | トライアル利用上限超過 |
| 20001 | TRY_ON_EXCEPTION | 処理エラー |
| 30001 | INVALID_API_KEY | APIキー不正 |
| 30002 | INVALID_SIGNATURE | リクエスト署名不正 |
レスポンス例
{
"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
}
}
コード例
画像URLでのCurl例
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例
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"'
Base64画像でのCurl例
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例
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例
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 : プロンプトで着せ替え
このAPIを利用するには、モデル画像と衣服説明プロンプトを提供する必要があります。
APIエンドポイント
POST https://changeclothesai.online/api/openapi/change-clothes-by-prompt
統合ガイド
リクエストヘッダー
| ヘッダー名 | 必須 | 説明 |
|---|---|---|
| content-type | はい | multipart/form-data である必要があります |
| authorization | はい | Bearer $ である必要があります。 $ はあなたのAPIキーです。 |
リクエストボディ FormData パラメータ
| パラメータ | 型 | 必須 | 説明 |
|---|---|---|---|
| modelImg | string または file | はい | モデル画像。3つの入力形式をサポート: 1. モデル画像URL(http://またはhttps://で始まる) 2. Base64エンコード画像(例: data:image/jpeg;base64,/9j/4AAQSkZJR... 他の画像タイプも可、mime-typeを調整) 3. ファイルオブジェクト(画像ファイル) |
| prompt | string | はい | 英語での着せ替えプロンプト。 例:Help the model change into a blue striped shirt. |
| seed | string | いいえ | AIプロセス開始用シード。0~2147483647の範囲。オプション。randomize_seedがtrueの場合は上書きされます。 |
| randomize_seed | string | いいえ | ランダムシード生成。enum: true, false。 |
| guidance_scale | string | いいえ | プロンプトの影響度を設定。数値型、範囲1-100。大きいほど影響度が高い。オプション、デフォルト50。必要な場合のみ調整推奨。 |
| num_inference_steps | string | いいえ | 画像生成のイテレーション回数。数値型、範囲1-50。オプション、デフォルト28。必要な場合のみ調整推奨。 |
レスポンスJSON形式
| フィールド | 型 | 説明 |
|---|---|---|
| code | number | レスポンスステータスコード。200は成功。 |
| msg | string | レスポンスメッセージ、追加情報を提供 |
| data | object | レスポンスデータオブジェクト。codeが200の時に存在 |
| data.resultImgUrl | string | 結果画像のURL |
| data.seed | number | 画像生成に使用したシード |
レスポンスコード
| コード | メッセージ | 説明 |
|---|---|---|
| 200 | OK | リクエスト成功 |
| 500 | SERVER_ERROR | サーバー内部エラー |
| 10001 | NOT_LOGIN | ユーザー未認証 |
| 10002 | USER_NOT_EXIST | ユーザーが存在しない |
| 10003 | INSUFFICIENT_CREDITS | クレジット不足 |
| 10004 | INVALID_PARAM | パラメータ不正 |
| 10005 | HARMFUL_CONTENT | 有害なコンテンツ検出 |
| 10006 | INSUFFICIENT_TRAIL_COUNT | トライアル利用上限超過 |
| 20001 | TRY_ON_EXCEPTION | 処理エラー |
| 30001 | INVALID_API_KEY | APIキー不正 |
| 30002 | INVALID_SIGNATURE | リクエスト署名不正 |
レスポンス例
{
"code": 200,
"data":
{
"resultImgUrl": "https://r2.changeclothesai.online/1748486113268661990.webp",
"seed": 627512067
}
}
コード例
画像URLでのCurl例
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例
# 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."'
Base64画像でのCurl例
# 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例
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例
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)}
料金
APIコールはアカウントのクレジットを消費します。クレジットは料金ページで購入できます。
ヘルプ & サポート
ご質問やサポートが必要な場合は、サポートチームまでお気軽にご連絡ください。
Email: dreamspire.team@gmail.com