Tính năng · Trang phục

Virtual try-on API cho trang phục

Tóm tắt trong một câu

Virtual try-on API của Photta nhận ảnh trang phục trải sàn cùng mannequin ID và trả về ảnh mẫu mặc đồ độ phân giải 2K hoặc 4K. POST job, polling mỗi 3–5 giây, tải xuống khi status là completed.

  • Thời gian điển hình: 1–1.5 min
  • Credits: 5 credits ở 2K · 6 credits ở 4K
  • Xử lý: async, polling
  • Giới hạn: 600 requests/min
  • Xác thực: Bearer key

Mọi số liệu trên trang này đều lấy từ tài liệu Photta API · đã kiểm tra

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": "tshirt",
  "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
Kết quả mẫu

Tổng quan nhanh

Tổng quan nhanh

Endpoint
POST /api/v1/tryon/apparel
Xác thực
Bearer API key
Xử lý
Bất đồng bộ — polling status endpoint
Thời gian điển hình
1–1.5 min
Credits
5 credits ở 2K · 6 credits ở 4K
Tỷ lệ khung hình
3:4 · 1:1 · 4:3 · 2:3 · 3:2 · 4:5 · 5:4 · 9:16 · 16:9 · 21:9
Giới hạn đầu vào
Tối đa 10 MB mỗi ảnh; JPEG, PNG, WebP
Idempotent
Có

Request và response

Request

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": "tshirt",
  "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 / Completed

{
  "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"
}

Tham số request

product_type

Kiểu: stringBắt buộc

Type of garment.

Giá trị: topbottomtop_and_bottomone_piece
product_images

Kiểu: array[string]Bắt buộc

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

Kiểu: 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

Kiểu: string

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

top_back_image

Kiểu: string

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

bottom_image

Kiểu: string

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

bottom_back_image

Kiểu: string

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

mannequin_id

Kiểu: stringBắt buộc

ID of the mannequin to wear the garment, from GET /api/v1/mannequins: one of Photta's, or one of your workspace's own while it is active. Another account's model, or one that was removed, is a 404; a jewellery or eyewear model is a 400.

background_color

Kiểu: 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.

Giá trị: whitelight_graygraycharcoalblackbeigecreamsand
pose_id

Kiểu: string

RETIRED 2026-08-10 — accepted and ignored. Poses were removed from apparel try-on; every generation is now a straight, relaxed, camera-facing shot (full length; a `top` is framed three-quarter). Sending it returns Deprecation and Sunset headers. Deleted 2027-02-10 — stop sending it.

background

Kiểu: 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

Kiểu: 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

Kiểu: string

Output resolution.

= 2K

Giá trị: 2K4K
aspect_ratio

Kiểu: string

Output aspect ratio.

= 3:4

Giá trị: 3:41:14:32:33:24:55:49:1616:921:9
body_size

Kiểu: string

Build of the model. The letter sizes map onto builds: XS → petite, S → slim, M → regular, L → curvy, XL and XXL → plus size. The build names (`petite`, `slim`, `regular`, `athletic`, `curvy`, `plus_size`) are accepted too. An unknown value adds no build to the prompt. A child model is always drawn with a child's build, whatever is sent.

= M

Giá trị: XSSMLXLXXLpetiteslimregularathleticcurvyplus_size
expression

Kiểu: string

Facial expression. `happy` and `smiling` are both a soft smile. An unknown value adds no expression to the prompt.

= neutral

Giá trị: neutralsoft_smileconfidentseriousrelaxedhappysmiling
footwear_url

Kiểu: string

URL or base64 of a custom footwear image. It is worn when the feet are in frame (full-length shots; a `top` is framed three-quarter).

user_instruction

Kiểu: 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

Kiểu: string

The kind of garment, as a category key (e.g. "tshirt", "jeans", "blazer", "mididress"; lower-case, no separators). It names the garment in the prompt's length sentence; an unknown key reads as "garment". Used for product_type "top", "bottom", and "one_piece". REQUIRED when `mannequin_id` is a child model: without it the request is a 400 (`param: "product_category"`), and swimwear or underwear on a child model is a 400 `content_policy_violation`, both before anything is charged.

top_category

Kiểu: string

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

bottom_category

Kiểu: string

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

length

Kiểu: 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

Kiểu: 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

Kiểu: 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

Kiểu: 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

Kiểu: 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

Kiểu: 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.

Lỗi

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, or (background removal) a free account has used its three cut-outs. Branch on the code.
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 or background_removal_unavailable). Retry later with backoff.

Giới hạn

  • 600 request mỗi phút trên mỗi tài khoản (Fixed window; giới hạn như nhau trên mọi gói)
  • Mã 429 kèm header Retry-After: 30 giây
  • Tối đa 10 MB mỗi ảnh
  • Định dạng: JPEG, PNG, WebP
  • Batch đồng thời theo từng gói: Free 1 · Hobby 2 · Seller 3 · Brand 4 · Studio 6
  • Chỉ hỗ trợ polling — API không gửi webhook.

Năm bước, một ảnh sản phẩm

Chọn một mannequin, gửi job, polling cho đến khi hoàn tất, tải kết quả về.

  1. Bước 1

    Tạo một API key

    Đăng ký tại ai.photta.app, mở tab Developers, nhấp Generate API key. Live key bắt đầu bằng `photta_live_`. Đặt key vào `PHOTTA_API_KEY` — tuyệt đối không commit.

  2. Bước 2

    Chọn mannequin

    GET `/api/v1/mannequins` để lấy danh sách người mẫu khả dụng và chọn ID bạn muốn. Tư thế đã ngừng hoạt động vào ngày 2026-08-10: mọi bức ảnh đều chụp toàn thân thẳng, hướng về phía camera, vì vậy không còn gì khác để chọn.

  3. Bước 3

    POST job try-on

    Gửi một POST đến `/api/v1/tryon/apparel` với `product_type`, `product_images`, `mannequin_id` cùng `resolution` và `aspect_ratio` tùy chọn. API trả về 202 Accepted kèm generation ID.

  4. Bước 4

    Polling cho đến khi job hoàn tất

    GET `/api/v1/tryon/apparel/:id` mỗi 3 giây. Khi `data.status` chuyển sang `completed`, payload sẽ bao gồm `output_url` và `thumbnail_url`. Hãy đặt giới hạn trên để job bị treo không làm nghẽn request của bạn.

  5. Bước 5

    Tải về và lưu trữ

    Fetch các byte từ `output_url` và lưu chúng vào object storage của riêng bạn. URL CDN ổn định nhưng sản phẩm của bạn không nên phụ thuộc vào nó để render.

Những câu hỏi lập trình viên đặt ra trước khi triển khai try-on trang phục

API virtual try-on của Photta là gì?

Một REST endpoint nhận ảnh sản phẩm chụp trải sàn (flat-lay) cùng mannequin ID và trả về ảnh mặc trên người mẫu chân thực. Cùng một pipeline với ứng dụng cho người dùng cuối của Photta. Hỗ trợ 4 loại sản phẩm: top, bottom, top+bottom, one-piece.

Chi phí mỗi lượt gọi là bao nhiêu?

5 credits cho kết quả 2K, 6 credits cho 4K. Credits đi kèm gói thuê bao của bạn và có thể nạp thêm. Các lượt tạo thất bại không tốn credits — chúng sẽ được hoàn lại.

Mất bao lâu để hoàn tất một lượt tạo?

Thời gian hoàn tất thông thường từ 1.5 đến 4 phút, đo lường toàn trình (end to end). Lệnh POST trả về generation ID trong chưa đầy 1 giây; GPU xử lý ngầm trong khi bạn polling.

Những loại sản phẩm nào được hỗ trợ?

Bốn loại: `top`, `bottom`, `top_and_bottom`, `one_piece`. Mỗi loại yêu cầu cấu trúc `product_images` khác nhau — ví dụ `top_and_bottom` cần cả URL của `top_image` lẫn `bottom_image`.

Tôi có thể dùng mannequin của riêng mình không?

Được. Tải ảnh mannequin lên bằng `POST /api/v1/mannequins` hoặc tạo một AI mannequin mới bằng `POST /api/v1/mannequins/generate`. ID trả về có thể gắn trực tiếp vào request try-on.

Tôi polling kết quả như thế nào?

GET `/api/v1/tryon/apparel/:id` mỗi 3 đến 5 giây cho đến khi `data.status` là `completed` hoặc `failed`. Hãy đặt giới hạn trên cho số lần thử — 120 × 3s là thừa đủ bao trọn khoảng thời gian theo tài liệu.

Các tính năng liên quan

Mọi số liệu trên trang này đều lấy từ tài liệu Photta API · đã kiểm tra

Thử nghiệm API trong năm phút

Tạo một Photta API key, dán đoạn mã cURL ở trên, và bạn sẽ nhận được bức ảnh mẫu mặc đồ đầu tiên trước khi pha xong ly cà phê.

  • 1–1.5 min
  • 5 credits ở 2K · 6 credits ở 4K
  • async, polling
  • 600 requests/min
  • Bearer key