Back to Home

Change Clothes AI API ドキュメント

2025-05-28

Posted by

Change Clothes AI API ドキュメント

はじめに & ユースケース

Change Clothes AI APIは、開発者がモデル画像にバーチャル衣服を簡単に適用できるAPIです。Eコマース、バーチャル試着、ファッションスタイリング、コンテンツ制作などのシナリオに最適です。オンライン試着体験を提供したい場合や、コンテンツ制作者が多様なコーディネート画像を生成したい場合、このAPIは効率とユーザー体験を大幅に向上させます。

主なユースケース

  • Eコマースプラットフォームでバーチャル試着を提供し、コンバージョン率を向上
  • ファッションスタイリングアプリでコーディネートプレビューを生成
  • コンテンツ制作者が衣服の組み合わせ画像を一括生成
  • ファッションデザイナーが新しい衣服デザインをモデルでプレビュー
  • AIアバターやバーチャルキャラクターの衣装チェンジ

APIキー

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 パラメータ

パラメータ必須説明
modelImgstring または fileはいモデル画像。3つの入力形式をサポート:
1. モデル画像URLhttp://またはhttps://で始まる)
2. Base64エンコード画像(例: data:image/jpeg;base64,/9j/4AAQSkZJR... 他の画像タイプも可、mime-typeを調整)
3. ファイルオブジェクト(画像ファイル)
garmentImgstring または fileはい衣服画像。modelImgと同じ3つの入力形式をサポート
categorystringはい衣服カテゴリ、enum: upper_body, lower_body, dresses
garmentDescstringいいえオプションの衣服説明(英語)

レスポンスJSON形式

フィールド説明
codenumberレスポンスステータスコード。200は成功。
msgstringレスポンスメッセージ、追加情報を提供
dataobjectレスポンスデータオブジェクト。codeが200の時に存在
data.resultImgUrlstring結果画像のURL
data.maskImgUrlstringインペイントマスク付きモデル画像のURL
data.cacheHitbooleanプリセットモデル・衣服画像の場合キャッシュヒット時true
プリセットモデル・衣服のみキャッシュ
レスポンスコード
コードメッセージ説明
200OKリクエスト成功
500SERVER_ERRORサーバー内部エラー
10001NOT_LOGINユーザー未認証
10002USER_NOT_EXISTユーザーが存在しない
10003INSUFFICIENT_CREDITSクレジット不足
10004INVALID_PARAMパラメータ不正
10005HARMFUL_CONTENT有害なコンテンツ検出
10006INSUFFICIENT_TRAIL_COUNTトライアル利用上限超過
20001TRY_ON_EXCEPTION処理エラー
30001INVALID_API_KEYAPIキー不正
30002INVALID_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 パラメータ

パラメータ必須説明
modelImgstring または fileはいモデル画像。3つの入力形式をサポート:
1. モデル画像URLhttp://またはhttps://で始まる)
2. Base64エンコード画像(例: data:image/jpeg;base64,/9j/4AAQSkZJR... 他の画像タイプも可、mime-typeを調整)
3. ファイルオブジェクト(画像ファイル)
promptstringはい英語での着せ替えプロンプト。
例:Help the model change into a blue striped shirt.
seedstringいいえAIプロセス開始用シード。0~2147483647の範囲。オプション。randomize_seedがtrueの場合は上書きされます。
randomize_seedstringいいえランダムシード生成。enum: true, false。
guidance_scalestringいいえプロンプトの影響度を設定。数値型、範囲1-100。大きいほど影響度が高い。オプション、デフォルト50。必要な場合のみ調整推奨。
num_inference_stepsstringいいえ画像生成のイテレーション回数。数値型、範囲1-50。オプション、デフォルト28。必要な場合のみ調整推奨。

レスポンスJSON形式

フィールド説明
codenumberレスポンスステータスコード。200は成功。
msgstringレスポンスメッセージ、追加情報を提供
dataobjectレスポンスデータオブジェクト。codeが200の時に存在
data.resultImgUrlstring結果画像のURL
data.seednumber画像生成に使用したシード
レスポンスコード
コードメッセージ説明
200OKリクエスト成功
500SERVER_ERRORサーバー内部エラー
10001NOT_LOGINユーザー未認証
10002USER_NOT_EXISTユーザーが存在しない
10003INSUFFICIENT_CREDITSクレジット不足
10004INVALID_PARAMパラメータ不正
10005HARMFUL_CONTENT有害なコンテンツ検出
10006INSUFFICIENT_TRAIL_COUNTトライアル利用上限超過
20001TRY_ON_EXCEPTION処理エラー
30001INVALID_API_KEYAPIキー不正
30002INVALID_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