Funzionalità · Abbigliamento

API di Virtual try-on per abbigliamento

In sintesi

L'API di virtual try-on di Photta riceve l'immagine flat-lay di un capo, un mannequin ID e un pose ID e restituisce una foto con modello in 2K o 4K. Invia il job via POST, esegui il polling ogni 3–5 secondi, scarica il file quando lo status è completed.

  • Tempo tipico: 1.5–4 min
  • Credits: 5 credits a 2K · 6 credits a 4K
  • Elaborazione: asincrono, polling
  • Limiti: 600 richieste/min
  • Autenticazione: Chiave Bearer

Ogni dato in questa pagina proviene da la documentazione dell'API di Photta · verificato

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",
  "pose_id": "pose_c2d4e5",
  "background": "https://cdn.yourstore.com/backgrounds/studio-loft.jpg",
  "lock_background": true,
  "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
Esempio di output

Panoramica

Panoramica

Endpoint
POST /api/v1/tryon/apparel
Autenticazione
API key Bearer
Elaborazione
Asincrona — effettua il polling dell'endpoint di stato
Tempo tipico
1.5–4 min
Credits
5 credits a 2K · 6 credits a 4K
Rapporti d'aspetto
3:4 · 1:1 · 4:3 · 9:16 · 16:9
Limiti di input
Fino a 10 MB per immagine; JPEG, PNG, WebP
Idempotente
No

Richiesta e risposta

Richiesta

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",
  "pose_id": "pose_c2d4e5",
  "background": "https://cdn.yourstore.com/backgrounds/studio-loft.jpg",
  "lock_background": true,
  "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 / Completato

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

Parametri della richiesta

product_type

Tipo: stringObbligatorio

Type of garment.

Valori: topbottomtop_and_bottomone_piece
product_images

Tipo: array[string]Obbligatorio

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

Tipo: string

Optional URL or base64 data URI for the BACK of the garment. When supplied, the pipeline auto-switches to the back image whenever the selected pose is back-facing (Back / BackCloseUp). Not used when product_type is "top_and_bottom".

top_image

Tipo: string

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

top_back_image

Tipo: string

Optional back image of the top garment. Auto-selected on back-facing poses when present.

bottom_image

Tipo: string

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

bottom_back_image

Tipo: string

Optional back image of the bottom garment. Auto-selected on back-facing poses when present.

mannequin_id

Tipo: stringObbligatorio

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

pose_id

Tipo: stringObbligatorio

ID of the pose. Use GET /api/v1/poses to list available options. The pose dictates the framing of the output — what's in frame, whether the face/feet are visible, full body vs half body, etc.

background

Tipo: string

Optional URL or base64 data URI to a background photo. Anything that is not a URL or data: URI is rejected with HTTP 400. When omitted, an editorial neutral backdrop is used.

lock_background

Tipo: boolean

When true, the supplied background image is reproduced faithfully (locked) instead of being treated as loose inspiration. Requires the background field — returns 400 if set without a background. Echoed back in the response object.

= false

resolution

Tipo: string

Output resolution. 4K cannot be combined with aspect_ratio 1:1 — that combination returns 400.

= 2K

Valori: 2K4K
aspect_ratio

Tipo: string

Output aspect ratio. 1:1 cannot be combined with resolution 4K — that combination returns 400.

= 3:4

Valori: 3:41:14:39:1616:9
body_size

Tipo: string

Body size of the mannequin.

= M

Valori: XSSMLXLXXL
expression

Tipo: string

Facial expression.

= neutral

Valori: neutralhappyserioussmiling
footwear_url

Tipo: string

URL or base64 of a custom footwear image. The pipeline always stages the footwear when supplied; the prompt's pose-authority block decides whether to render it (poses that don't show feet drop it cleanly).

user_instruction

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

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

Tipo: string

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

bottom_category

Tipo: string

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

length

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

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

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

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

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

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

Errori

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. Retry later.

Limiti

  • 600 richieste al minuto per API key (Finestra fissa; il limite è lo stesso per ogni piano)
  • Un 429 restituisce Retry-After: 30 secondi
  • Fino a 10 MB per immagine
  • Formati: JPEG, PNG, WebP
  • Batch simultanei per piano: Free 1 · Hobby 2 · Seller 3 · Brand 4 · Studio 6
  • Solo polling — l'API non invia webhook.

Cinque passaggi, una sola foto prodotto

Scegli un manichino, invia il job, fai polling fino al completamento, scarica il risultato.

  1. Passaggio 1

    Genera una chiave API

    Registrati su ai.photta.app, apri la scheda Developers, fai clic su Generate API key. Le chiavi live iniziano con `photta_live_`. Inserisci la chiave in `PHOTTA_API_KEY` — non committarla mai.

  2. Passaggio 2

    Scegli un manichino e una posa

    GET `/api/v1/mannequins` per elencare le opzioni disponibili. GET `/api/v1/poses` per l'inquadratura. Entrambi gli ID vanno nella richiesta di try-on.

  3. Passaggio 3

    Invia il job di try-on tramite POST

    Invia una POST a `/api/v1/tryon/apparel` con `product_type`, `product_images`, `mannequin_id`, `pose_id` e i parametri opzionali `resolution` e `aspect_ratio`. L'API restituisce 202 Accepted con un generation ID.

  4. Passaggio 4

    Fai polling fino al completamento del job

    GET `/api/v1/tryon/apparel/:id` ogni 3 secondi. Quando `data.status` passa a `completed`, il payload include `output_url` e `thumbnail_url`. Imposta un limite massimo per evitare che un job bloccato blocchi la tua richiesta.

  5. Passaggio 5

    Scarica e rendi persistente

    Esegui il fetch dei byte da `output_url` e salvali nel tuo object storage. L'URL della CDN è stabile, ma il tuo prodotto non dovrebbe dipendere da esso per il rendering.

Domande frequenti degli sviluppatori prima di rilasciare il try-on per abbigliamento

Cos'è l'API di virtual try-on di Photta?

Un endpoint REST che riceve un'immagine del prodotto in flat-lay e un mannequin ID, restituendo un'immagine fotorealistica indossata da un modello. Stessa pipeline dell'app consumer di Photta. Sono supportati quattro tipi di prodotto: top, bottom, top+bottom, one-piece.

Quanto costa per chiamata?

5 credits per un risultato in 2K, 6 credits per 4K. I credits sono inclusi nel tuo abbonamento e possono essere ricaricati. Le generazioni con stato failed non costano credits — vengono rimborsate.

Quanto tempo richiede una generazione?

Il completamento tipico richiede da 1.5 a 4 minuti, misurati end-to-end. La POST restituisce un generation ID in meno di un secondo; il carico di lavoro su GPU avviene in background mentre esegui il polling.

Quali tipi di prodotto sono supportati?

Quattro: `top`, `bottom`, `top_and_bottom`, `one_piece`. Ognuno richiede una struttura specifica per `product_images` — per esempio `top_and_bottom` richiede entrambi gli URL `top_image` e `bottom_image`.

Posso usare il mio manichino?

Sì. Carica la foto di un manichino con `POST /api/v1/mannequins` o genera un nuovo manichino AI con `POST /api/v1/mannequins/generate`. L'ID restituito si inserisce direttamente nella richiesta di try-on.

Come eseguo il polling del risultato?

GET `/api/v1/tryon/apparel/:id` ogni 3-5 secondi finché `data.status` non diventa `completed` o `failed`. Imposta un limite massimo sui tentativi — 120 × 3s copre la finestra temporale documentata con ampio margine.

Funzionalità correlate

Ogni dato in questa pagina proviene da la documentazione dell'API di Photta · verificato

Prova l'API in 5 minuti

Genera una chiave API di Photta, incolla lo snippet cURL qui sopra e otterrai la tua prima immagine con modello prima ancora che il caffè sia pronto.

  • 1.5–4 min
  • 5 credits a 2K · 6 credits a 4K
  • asincrono, polling
  • 600 richieste/min
  • Chiave Bearer