Förmåga · Apparel

API för virtuell try-on för apparel

I en mening

Phottas API för virtuell try-on tar en flat-lay-klädbild och ett mannekäng-ID och returnerar ett foto på modell i 2K eller 4K. POST:a jobbet, polla var 3–5:e sekund, ladda ner när status är completed.

  • Typisk tid: 1–1.5 min
  • Credits: 5 credits vid 2K · 6 credits vid 4K
  • Bearbetning: asynkron, polling
  • Gränser: 600 requests/min
  • Autentisering: Bearer-nyckel

Varje siffra på den här sidan kommer från Photter API-dokumentationen · kontrollerad

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
Exempelutdata

I korthet

I korthet

Endpoint
POST /api/v1/tryon/apparel
Autentisering
Bearer API-nyckel
Bearbetning
Asynkron — polla status-endpointen
Typisk tid
1–1.5 min
Credits
5 credits vid 2K · 6 credits vid 4K
Bildförhållanden
3:4 · 1:1 · 4:3 · 2:3 · 3:2 · 4:5 · 5:4 · 9:16 · 16:9 · 21:9
Indatagränser
Upp till 10 MB per bild; JPEG, PNG, WebP
Idempotent
Ja

Request och 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"
}

Request-parametrar

product_type

Typ: stringObligatorisk

Type of garment.

Värden: topbottomtop_and_bottomone_piece
product_images

Typ: array[string]Obligatorisk

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

Typ: 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

Typ: string

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

top_back_image

Typ: string

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

bottom_image

Typ: string

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

bottom_back_image

Typ: string

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

mannequin_id

Typ: stringObligatorisk

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

Typ: 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.

Värden: whitelight_graygraycharcoalblackbeigecreamsand
pose_id

Typ: 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

Typ: 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

Typ: 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

Typ: string

Output resolution.

= 2K

Värden: 2K4K
aspect_ratio

Typ: string

Output aspect ratio.

= 3:4

Värden: 3:41:14:32:33:24:55:49:1616:921:9
body_size

Typ: 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

Värden: XSSMLXLXXLpetiteslimregularathleticcurvyplus_size
expression

Typ: string

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

= neutral

Värden: neutralsoft_smileconfidentseriousrelaxedhappysmiling
footwear_url

Typ: 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

Typ: 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

Typ: 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

Typ: string

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

bottom_category

Typ: string

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

length

Typ: 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

Typ: 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

Typ: 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

Typ: 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

Typ: 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

Typ: 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.

Fel

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.

Gränser

  • 600 anrop per minut per konto (Fast fönster; gränsen är densamma på alla planer)
  • En 429 innehåller Retry-After: 30 sekunder
  • Upp till 10 MB per bild
  • Format: JPEG, PNG, WebP
  • Samtidiga batcher per plan: Free 1 · Hobby 2 · Seller 3 · Brand 4 · Studio 6
  • Endast polling — API:et skickar inga webhooks.

Fem steg, ett produktfoto

Välj en provdocka, skicka jobbet, polla tills det är klart, ladda ned resultatet.

  1. Steg 1

    Generera en API-nyckel

    Skapa konto på ai.photta.app, öppna fliken Developers, klicka på Generate API key. Produktionsnycklar börjar med `photta_live_`. Sätt nyckeln i `PHOTTA_API_KEY` — committa den aldrig.

  2. Steg 2

    Välj provdocka

    GET `/api/v1/mannequins` för att lista tillgängliga modeller och ta det ID du vill ha. Poser pensionerades den 2026-08-10: varje bild är en rak helkroppsvinkel vänd mot kameran, så det finns inget annat att välja.

  3. Steg 3

    Gör en POST med try-on-jobbet

    Skicka en POST till `/api/v1/tryon/apparel` med `product_type`, `product_images`, `mannequin_id` samt valfria `resolution` och `aspect_ratio`. API:et returnerar 202 Accepted med ett genererings-ID.

  4. Steg 4

    Polla tills jobbet är klart

    GET `/api/v1/tryon/apparel/:id` var 3:e sekund. När `data.status` slår om till `completed` innehåller payloaden `output_url` och `thumbnail_url`. Sätt en övre gräns så att ett låst jobb inte hänger din request.

  5. Steg 5

    Ladda ned och spara

    Hämta byten från `output_url` och lagra dem i din egen objektlagring. CDN-URL:en är stabil, men din produkt bör inte förlita sig på den för rendering.

Frågor utvecklare ställer innan de driftsätter apparel try-on

Vad är Phottas API för virtuell try-on?

En REST-endpoint som tar en flat-lay-produktbild och ett provdocke-ID och returnerar en fotorealistisk bild på modell. Samma pipeline som Phottas konsumentapp. Fyra produkttyper stöds: top, bottom, top+bottom, one-piece.

Vad kostar det per anrop?

5 credits för ett 2K-resultat, 6 credits för 4K. Credits ingår i din prenumeration och kan fyllas på. Misslyckade genereringar kostar inga credits — de återbetalas.

Hur lång tid tar en generering?

Normal svarstid är 1,5 till 4 minuter, mätt från start till mål. POST-anropet returnerar ett genererings-ID på under en sekund; GPU-arbetet sker i bakgrunden medan du pollar.

Vilka produkttyper stöds?

Fyra: `top`, `bottom`, `top_and_bottom`, `one_piece`. Var och en förväntar sig en specifik struktur på `product_images` — till exempel kräver `top_and_bottom` URL:er för både `top_image` och `bottom_image`.

Kan jag använda min egen provdocka?

Ja. Ladda upp ett foto på en provdocka med `POST /api/v1/mannequins` eller generera en ny AI-provdocka med `POST /api/v1/mannequins/generate`. Det returnerade ID:t används direkt i try-on-anropet.

Hur pollar jag efter resultatet?

GET `/api/v1/tryon/apparel/:id` var 3:e till 5:e sekund tills `data.status` är `completed` eller `failed`. Sätt en övre gräns för antalet försök — 120 × 3s täcker det dokumenterade tidsfönstret med god marginal.

Relaterade funktioner

Varje siffra på den här sidan kommer från Photter API-dokumentationen · kontrollerad

Testa API:et på fem minuter

Generera en Photta API-nyckel, klistra in cURL-kodfragmentet ovan, och du har din första bild på en modell innan kaffet har bryggts klart.

  • 1–1.5 min
  • 5 credits vid 2K · 6 credits vid 4K
  • asynkron, polling
  • 600 requests/min
  • Bearer-nyckel