用途:FASHN 专注时尚领域的人像生成模型,可用于虚拟试穿、商品图转模特上身、生成模特、替换模特身份、头像转半身形象、自由编辑、改画幅、去背景以及图片转视频。所有能力通过同一预测端点调用,请求体为 { model_name, inputs }。
主要能力与模型:tryon-max(虚拟试穿,需 model_image、product_image)、tryon-v1.6(旧版快速试穿,需 model_image、garment_image)、product-to-model(需 product_image)、model-create(需 prompt)、model-swap(需 model_image)、face-to-model(需 face_image)、edit(需 image、prompt)、reframe(需 image、aspect_ratio)、background-remove(需 image)、image-to-video(需 image)。
使用方式:需从 https://app.fashn.ai/api 获取 API Key,所有调用均在服务端进行,切勿硬编码或暴露到客户端。REST 使用 Authorization: Bearer $FASHN_API_KEY,基础地址 https://api.fashn.ai/v1;SDK 默认读取环境变量 FASHN_API_KEY。TypeScript 安装 npm install fashn,Python 安装 pip install fashn。推荐用 subscribe 提交并自动轮询至终态;也可用 run 获取 id 后轮询 status。REST 提交示例:curl -s -X POST https://api.fashn.ai/v1/run -H "Authorization: Bearer $FASHN_API_KEY" -H "Content-Type: application/json" -d '{"model_name":"tryon-max","inputs":{"model_image":"...","product_image":"..."}}',再轮询 /v1/status/<id>。可用 GET /v1/credits 查余额,/run 加 ?webhook_url= 可免轮询。
限制与注意:状态流转为 starting→in_queue→processing→completed|failed;失败不计费,费用随 generation_mode 与分辨率变化。错误分 API 错误(4xx/5xx)与运行时错误(HTTP 200 但 status 为 failed),需始终判断 status。批量时对 429 做退避。webhook 无签名头,需幂等并快速返回 2xx。完整参数、错误目录与定价见 reference.md。