Virtual Try-On

April 18, 2025

Table of contents

  1. Request Headers
  2. Request Body
  3. Responses
  4. Model
  5. Examples
  6. Try It

This endpoint allows you to create virtual try-on images with Kling AI by providing a human image and clothing items.

https://api.useapi.net/v1/kling/images/virtual-try-on

Request Headers
Authorization: Bearer {API token}
Content-Type: application/json
# Alternatively you can use multipart/form-data
# Content-Type: multipart/form-data
Request Body
{
  "email": "[email protected]",
  "humanImage": "https://example.com/person.jpg",
  "dressInput": "https://example.com/dress.jpg",
  "imageCount": 2,
  "replyUrl": "https://your-callback-url.com/webhook",
  "replyRef": "your-reference-id"
}
  • email is optional when only one account configured. However, if you have multiple accounts configured, this parameter becomes required.
  • humanImage is required, URL to the image of a person. Must be a valid http/https URL. Images can be uploaded using POST /assets and the returned URLs can be used here.
  • dressInput URL to a full-dress image to try on. Incompatible with upperInput and lowerInput. Images can be uploaded using POST /assets.
  • upperInput URL to an upper garment image. Incompatible with dressInput. Images can be uploaded using POST /assets.
  • lowerInput URL to a lower garment image. Incompatible with dressInput. Images can be uploaded using POST /assets.
  • imageCount is optional, range from 1 to 4. Default is 1.
  • maxJobs is optional, range from 1 to 10. Specifies the maximum number of concurrent jobs.
  • replyUrl is optional, a callback URL to receive results when completed.
  • replyRef is optional, a reference identifier for the callback.

Note: You must provide at least one of: dressInput, upperInput, or lowerInput.

Responses
  • 200 OK

    {
      "id": 12345678,
      "created": 1712345678000,
      "status": "submitted",
      "status_final": false,
      "type": "mmu_img2img_aitryon",
      "taskInfo": {
        "inputs": [
          {
            "name": "humanImage",
            "url": "https://example.com/person.jpg"
          },
          {
            "name": "dressInput",
            "url": "https://example.com/dress.jpg"
          }
        ],
        "arguments": [
          {
            "name": "personType",
            "value": "Female"
          },
          {
            "name": "imageCount",
            "value": "2"
          }
        ]
      },
      "scheduled": true
    }
    
  • 400 Bad Request

    {
      "error": "At least one of dressInput, upperInput or lowerInput must be provided"
    }
    
  • 401 Unauthorized

    {
      "error": "Unauthorized",
      "code": 401
    }
    

When successful, the response includes a task ID which can be used to check the status using GET /tasks/{task_id}.

Model
{ // TypeScript, all fields are optional
  id: number          // Task ID
  created: number     // Creation timestamp in milliseconds
  status: string      // Task status: "submitted", "processing", "failed", or "succeed"
  status_final: boolean // Whether this is the final status of the task
  type: string        // Task type
  taskInfo: {
    inputs: Array<{
      name: string    // Input name
      url: string     // Input URL
    }>
    arguments: Array<{
      name: string    // Argument name
      value: string   // Argument value
    }>
  }
  scheduled: boolean  // Whether the task is scheduled
}
Examples
  • curl -X POST "https://api.useapi.net/v1/kling/images/virtual-try-on" \
       -H "Content-Type: application/json" \
       -H "Authorization: Bearer …" \
       -d '{
         "email": "[email protected]",
         "humanImage": "https://example.com/person.jpg",
         "dressInput": "https://example.com/dress.jpg",
         "imageCount": 2
       }'
    
  • const token = "API token";
    const email = "Previously configured account email";
    const apiUrl = "https://api.useapi.net/v1/kling/images/virtual-try-on"; 
    const response = await fetch(apiUrl, {
      method: "POST",
      headers: {
        "Content-Type": "application/json",
        "Authorization": `Bearer ${token}`,
      },
      body: JSON.stringify({
        email: email,
        humanImage: "https://example.com/person.jpg",
        dressInput: "https://example.com/dress.jpg",
        imageCount: 2
      })
    });
    const result = await response.json();
    console.log("response", {response, result});
    
  • import requests
    token = "API token"
    email = "Previously configured account email"
    apiUrl = "https://api.useapi.net/v1/kling/images/virtual-try-on"
    headers = {
        "Content-Type": "application/json", 
        "Authorization" : f"Bearer {token}"
    }
    data = {
        "email": email,
        "humanImage": "https://example.com/person.jpg",
        "dressInput": "https://example.com/dress.jpg",
        "imageCount": 2
    }
    response = requests.post(apiUrl, headers=headers, json=data)
    print(response, response.json())
    
Try It