fashn-logo
FASHNAI

Product to Model

Powered by best-in-class image editing AI, the Product to Model endpoint transforms product images into people wearing those products. It supports dual-mode operation: standard product-to-model (generates new person) and try-on mode (adds product to existing person).

This endpoint is designed specifically for wearable fashion items such as clothing, shoes, hats, jewelry, bags, and accessories.

Model Specifications
  • Model Name: product-to-model
  • Lifecycle: preview
  • Dual-Mode Operation: Product-only or Product + Model images
  • Processing Time: 12 seconds
  • Output Formats: PNG, JPEG
  • Delivery Methods: URL or Base64 encoding

Request

Generate product-to-model images by submitting your product and optional model images to the universal /v1/run endpoint:

POSThttps://api.fashn.ai/v1/run

Request Examples

curl -X POST https://api.fashn.ai/v1/run \
     -H "Content-Type: application/json" \
     -H "Authorization: Bearer YOUR_API_KEY" \
     -d '{
           "model_name": "product-to-model",
           "inputs": {
             "product_image": "http://example.com/path/to/product.jpg",
             "model_image": "http://example.com/path/to/person.jpg",
             "prompt": "professional office setting",
             "output_format": "png",
             "return_base64": false
           }
         }'

Response

Returns a prediction ID for status polling:

{
  "id": "123a87r9-4129-4bb3-be18-9c9fb5bd7fc1-u1",
  "error": null
}

Request Parameters

product_image
Required
image URL | base64

URL or base64 encoded image of the product to be worn. Supports clothing, accessories, shoes, and other wearable fashion items.

model_imageimage URL | base64

URL or base64 encoded image of the person to wear the product. When provided, enables try-on mode. When omitted, generates a new person wearing the product.

Default: None

promptstring

Additional instructions for person appearance (when model_image is not provided), styling preferences or background.

Examples: "man with tattoos", "tucked-in", "open jacket", "rolled-up sleeves", "studio background".

Default: None

aspect_ratiostring

Desired aspect ratio for the output image. Only applies when model_image is not provided (standard product-to-model mode).

When model_image is provided (try-on mode), this parameter is ignored and the output will match the model_image's aspect ratio.

Supported ratios: "1:1", "3:4", "4:3", "9:16", "16:9", "2:3", "3:2", "4:5", "5:4"

Default: product_image's aspect ratio (standard mode only)

seedinteger

Seed for reproducible results. Must be between 0 and 2^32-1.

Default: 42

output_formatstring

Output image format.

  • "png" - PNG format, original quality
  • "jpeg" - JPEG format, smaller file size

Default: "png"

return_base64boolean

When set to true, the API will return the generated image as a base64-encoded string instead of a CDN URL. The base64 string will be prefixed data:image/png;base64,....

This option offers enhanced privacy as user-generated outputs are not stored on our servers when return_base64 is enabled.

Default: false

Response Polling

After submitting your request, poll the status endpoint using the returned prediction ID. See API Fundamentals for complete polling details.

Successful Response

When your product-to-model generation completes successfully, the status endpoint will return:

{
  "id": "123a87r9-4129-4bb3-be18-9c9fb5bd7fc1-u1",
  "status": "completed",
  "output": [
    "https://cdn.fashn.ai/123a87r9-4129-4bb3-be18-9c9fb5bd7fc1-u1/output_0.png"
  ],
  "error": null
}

Runtime Errors

If an error occurs during inference (while running the model), the API will return a 200 status code with a prediction status: failed. Additionally, an error object will be included under the error key in the response.

NameCauseSolution
ImageLoadErrorThe pipeline was unable to load the product image or model image from the provided inputs.For Image URLs:
  • Ensure the URL is publicly accessible and not restricted by permissions.
  • Verify that the Content-Type header specifies the correct image format (e.g., image/jpeg, image/png).
For Base64-encoded images:
  • Prefix the string with data:image/format;base64, where format is the image type (e.g., jpeg, png).
ContentModerationErrorProhibited content detected in the provided product or model image. Content moderation is more sensitive when model_image contains an actual person (virtual try-on mode).
  • This endpoint operates with third-party processors that enforce strict content policies. Explicit or inappropriate imagery is prohibited, particularly when involving real people.
  • For legitimate use-cases involving intimate apparel such as lingerie or swimwear, use our FASHN Virtual Try-On endpoint where you have full control over content moderation settings.
  • Product photo generation without model_image provided operates under more permissive content policies.
  • All usage must comply with our Terms of Service.
  • If you believe your content was incorrectly flagged, contact support@fashn.ai with the prediction ID.
PipelineErrorAn unexpected error occurred during the execution of the pipeline.Retry the request (you will not be charged for failed attempts). If the issue persists, please reach out to us at support@fashn.ai and include the prediction ID from the failed attempt to help us locate and address the issue promptly.
ThirdPartyErrorA third-party processor failed or refused to handle the request.Most likely caused by content restrictions enforced by supporting services (e.g., image captioning). If that’s the case, try modifying your image inputs. If the issue persists across different inputs, contact support@fashn.ai with the prediction ID.

The Error Object

{
  "error": {
    "name": "PipelineError",
    "message": "The error message"
  }
}

Example of an error when polling the /status endpoint:

{
  "id": "123a87r9-4129-4bb3-be18-9c9fb5bd7fc1-u1",
  "status": "failed",
  "error": {
    "name": "ImageLoadError",
    "message": "Error loading product image: The URL's Content-Type is not an image. Content-Type: text/plain;charset=UTF-8"
  }
}

If you encounter an unrecognized error, please contact us at support@fashn.ai.

On this page