Capability · 服饰

虚拟 try-on API 适用于服装

一句话总结

Photta 的虚拟 try-on API 接收平铺服装图和模特 ID,返回 2K 或 4K 的上身模特大片。POST 提交任务,每隔 3–5 秒轮询 (poll),当状态为 completed 时即可下载。

  • 常规耗时: 1.5–4 min
  • Credits: 2K 分辨率 5 credits · 4K 分辨率 6 credits
  • 处理方式: 异步,轮询
  • 限制: 600 次请求/分钟
  • 身份验证: Bearer key

本页所有数据均来自 Photta API 文档 · 已验证

POST/api/v1/tryon/apparel
RESPONSE=$(curl -s -X POST https://api.photta.app/api/v1/tryon/apparel \
  -H "Authorization: Bearer $PHOTTA_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "product_type": "top",
  "product_images": [
    "https://cdn.yourstore.com/products/shirt-front.jpg"
  ],
  "product_back_image": "https://cdn.yourstore.com/products/shirt-back.jpg",
  "product_category": "t_shirt",
  "mannequin_id": "mnk_f3a9b1",
  "background_color": "#F5F0E8",
  "resolution": "2K",
  "aspect_ratio": "3:4",
  "body_size": "M",
  "expression": "neutral",
  "user_instruction": "Keep the collar pattern crisp and centered."
}')
ID=$(echo "$RESPONSE" | jq -r '.data.id')
A garment rendered on an AI model by the apparel try-on API
示例输出

概览

概览

端点
POST /api/v1/tryon/apparel
身份验证
Bearer API 密钥
处理方式
异步 — 轮询状态端点
常规耗时
1.5–4 min
Credits
2K 分辨率 5 credits · 4K 分辨率 6 credits
宽高比
3:4 · 1:1 · 4:3 · 2:3 · 3:2 · 4:5 · 5:4 · 9:16 · 16:9 · 21:9
输入限制
单张图片最大 10 MB;支持 JPEG, PNG, WebP
幂等性
否

请求与响应

请求

RESPONSE=$(curl -s -X POST https://api.photta.app/api/v1/tryon/apparel \
  -H "Authorization: Bearer $PHOTTA_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "product_type": "top",
  "product_images": [
    "https://cdn.yourstore.com/products/shirt-front.jpg"
  ],
  "product_back_image": "https://cdn.yourstore.com/products/shirt-back.jpg",
  "product_category": "t_shirt",
  "mannequin_id": "mnk_f3a9b1",
  "background_color": "#F5F0E8",
  "resolution": "2K",
  "aspect_ratio": "3:4",
  "body_size": "M",
  "expression": "neutral",
  "user_instruction": "Keep the collar pattern crisp and centered."
}')
ID=$(echo "$RESPONSE" | jq -r '.data.id')

202 Accepted / 已完成

{
  "data": {
    "id": "try_abc123",
    "status": "processing",
    "product_type": "top",
    "mannequin_id": "mnk_f3a9b1",
    "background_color": "#F5F0E8",
    "lock_background": false,
    "resolution": "2K",
    "aspect_ratio": "3:4",
    "credits_used": 5,
    "created_at": "2026-04-10T12:00:00Z"
  },
  "request_id": "req_xyz789"
}

请求参数

product_type

类型: string必填

Type of garment.

取值: topbottomtop_and_bottomone_piece
product_images

类型: array[string]必填

Array of image URLs or base64 data URIs. The first entry is the FRONT image and is required. Not used when product_type is "top_and_bottom".

product_back_image

类型: string

Optional URL or base64 data URI for the BACK of the garment. Sending one IS the request for a back shot: the model is photographed from behind and this image is the reference. Omit it and you get the front. There is deliberately no separate "view" field — two fields that can contradict each other. Not used when product_type is "top_and_bottom".

top_image

类型: string

Front image of the top garment. Required when product_type is "top_and_bottom".

top_back_image

类型: string

Optional back image of the top garment. Sending one asks for a back shot, exactly as product_back_image does.

bottom_image

类型: string

Front image of the bottom garment. Required when product_type is "top_and_bottom".

bottom_back_image

类型: string

Optional back image of the bottom garment. Sending one asks for a back shot, exactly as product_back_image does.

mannequin_id

类型: string必填

ID of the mannequin to wear the garment. Use GET /api/v1/mannequins to list available options.

background_color

类型: string

The backdrop, as a colour. One of white, light_gray, gray, charcoal, black, beige, cream, sand — or any hex value (#F5F0E8, F5F0E8, #fff). It travels to the engine as TEXT; nothing is uploaded, and the same value reproduces exactly on every run. Omit it for the engine's clean studio default. An unrecognised value returns 400 rather than quietly falling back. Echoed back on the response.

取值: whitelight_graygraycharcoalblackbeigecreamsand
pose_id

类型: string

RETIRED 2026-08-10 — accepted and ignored. Poses were removed from apparel try-on; every generation is now a straight, relaxed, camera-facing full-body shot (the old FullBody stance). Sending it returns Deprecation and Sunset headers. Deleted 2027-02-10 — stop sending it.

background

类型: string

RETIRED 2026-08-11 — accepted and ignored, never downloaded. Backdrop photographs were removed: recreating a room competed with the garment for the engine's attention. Use background_color instead. Sending it returns Deprecation and Sunset headers. Deleted 2027-02-10.

lock_background

类型: boolean

RETIRED 2026-08-11 — accepted and ignored, and always false on responses. It never worked as previously documented: the prompt engine has always discarded the flag, so the "faithful reproduction" this page used to promise was never delivered. background_color is the first backdrop control that actually holds still. Deleted 2027-02-10.

= false

resolution

类型: string

Output resolution.

= 2K

取值: 2K4K
aspect_ratio

类型: string

Output aspect ratio.

= 3:4

取值: 3:41:14:32:33:24:55:49:1616:921:9
body_size

类型: string

Body size of the mannequin.

= M

取值: XSSMLXLXXL
expression

类型: string

Facial expression.

= neutral

取值: neutralhappyserioussmiling
footwear_url

类型: string

URL or base64 of a custom footwear image. Every generation is a full-body shot, so supplied footwear is staged and worn.

user_instruction

类型: string

Free-form refinement, e.g. "preserve the seam pattern across the shoulder", "keep the collar contrast strong". Capped at 500 characters server-side; longer strings are silently truncated. Useful for brand-specific details that need an extra nudge.

product_category

类型: string

Optional silhouette anchor for the garment (e.g. "t_shirt", "jeans", "blazer", "midi_dress"). Helps disambiguate the structure of the garment when the silhouette is ambiguous from the photo alone. Used for product_type "top", "bottom", and "one_piece".

top_category

类型: string

Silhouette anchor for the top half. Only valid when product_type is "top_and_bottom".

bottom_category

类型: string

Silhouette anchor for the bottom half. Only valid when product_type is "top_and_bottom".

length

类型: string

Garment length key for product_type "top", "bottom", or "one_piece". List available values with GET /api/v1/garment-attributes?type=length&garment_type={product_type}.

fit

类型: string

Garment fit key for product_type "top", "bottom", or "one_piece". List available values with GET /api/v1/garment-attributes?type=fit&garment_type={product_type}.

top_length

类型: string

Top length key. Only valid when product_type is "top_and_bottom". List with GET /api/v1/garment-attributes?type=length&garment_type=top.

top_fit

类型: string

Top fit key. Only valid when product_type is "top_and_bottom". List with GET /api/v1/garment-attributes?type=fit&garment_type=top.

bottom_length

类型: string

Bottom length key. Only valid when product_type is "top_and_bottom". List with GET /api/v1/garment-attributes?type=length&garment_type=bottom.

bottom_fit

类型: string

Bottom fit key. Only valid when product_type is "top_and_bottom". List with GET /api/v1/garment-attributes?type=fit&garment_type=bottom.

错误

400invalid_request_error
The request is malformed or contains invalid parameters.
401authentication_error
The API key is missing, invalid, or expired.
402insufficient_credits_error
Your account does not have enough credits.
404not_found_error
The requested resource does not exist.
409conflict_error
The request conflicts with current state — e.g. your concurrent-batch cap is reached.
429rate_limit_error
Too many requests. Slow down and retry.Retry-After: 30
500api_error
An internal server error occurred (500), or a check your request needs could not run right now (503, e.g. moderation_unavailable). Retry later with backoff.

限制

  • 每个账户每分钟 600 次请求 (固定窗口;各套餐限制相同)
  • 429 响应包含 Retry-After: 30 秒
  • 单张图片最大 10 MB
  • 格式:: JPEG, PNG, WebP
  • 各套餐并发批处理数:: Free 1 · Hobby 2 · Seller 3 · Brand 4 · Studio 6
  • 仅支持轮询 — API 不发送 Webhook。

五个步骤,一张商品图

挑选模特,提交任务,轮询至完成,下载结果。

  1. 步骤 1

    生成 API Key

    在 ai.photta.app 注册,打开 Developers 标签页,点击 Generate API key。生产环境 Key 以 `photta_live_` 开头。将 Key 写入 `PHOTTA_API_KEY` ——切勿提交到代码库。

  2. 步骤 2

    挑选模特

    通过 GET `/api/v1/mannequins` 列出可用模特并获取所需 ID。姿态已于 2026-08-10 停用:每张成片均为正向平视全身照,因此无需另行挑选。

  3. 步骤 3

    POST 试穿任务

    向 `/api/v1/tryon/apparel` 发送 POST 请求,携带 `product_type`、`product_images`、`mannequin_id` 以及可选的 `resolution` 和 `aspect_ratio`。API 返回 202 Accepted 及生成任务 ID。

  4. 步骤 4

    轮询直至任务完成

    每 3 秒 GET `/api/v1/tryon/apparel/:id` 一次。当 `data.status` 变为 `completed` 时,payload 会包含 `output_url` 和 `thumbnail_url`。请设置轮询上限,防止任务卡死挂起请求。

  5. 步骤 5

    下载并持久化存储

    从 `output_url` 拉取字节流并转存到您自己的对象存储中。CDN URL 虽然稳定,但生产系统不应依赖它来进行前端渲染。

开发者上线服装试穿前常问的问题

什么是 Photta 虚拟试穿 API?

一个 REST endpoint,接收平铺商品图和模特 ID,返回逼真的上身效果图。底层采用与 Photta 消费端 App 相同的管线。支持四种商品类型:上装、下装、套装(上装+下装)、连体衣。

每次调用费用是多少?

2K 分辨率单次 5 credits,4K 为 6 credits。Credits 随订阅计划提供,支持随时充值。生成失败不扣除 credits —— 系统会自动退还。

生成一次需要多长时间?

端到端耗时通常为 1.5 到 4 分钟。POST 请求在 1 秒内返回生成任务 ID;在您轮询期间,GPU 渲染任务在后台异步执行。

支持哪些商品类型?

支持四种:`top`、`bottom`、`top_and_bottom`、`one_piece`。每种类型对应的 `product_images` 数据结构不同 —— 例如 `top_and_bottom` 需要同时传入 `top_image` 和 `bottom_image` 的 URL。

可以使用我自己的模特吗?

可以。通过 `POST /api/v1/mannequins` 上传模特照片,或通过 `POST /api/v1/mannequins/generate` 生成新的 AI 模特。返回的 ID 可直接填入试穿请求中。

如何轮询获取结果?

每 3 到 5 秒 GET `/api/v1/tryon/apparel/:id` 一次,直到 `data.status` 变为 `completed` 或 `failed`。请设置尝试次数上限 —— 120 × 3s 足以覆盖文档标明的耗时窗口并留有余量。

相关能力

本页所有数据均来自 Photta API 文档 · 已验证

五分钟内上手试用 API

生成 Photta API key,粘贴上方的 cURL 代码片段,咖啡还没煮好,您的第一张模特实穿图就已经生成完毕。

  • 1.5–4 min
  • 2K 分辨率 5 credits · 4K 分辨率 6 credits
  • 异步,轮询
  • 600 次请求/分钟
  • Bearer key