Fonctionnalité · Apparel

API de try-on virtuel pour les vêtements

En une phrase

L'API de try-on virtuel de Photta prend une photo de vêtement à plat et un mannequin_id, puis renvoie une photo portée sur modèle en 2K ou 4K. Envoyez le job en POST, interrogez le statut toutes les 3–5 secondes, téléchargez lorsque le statut est completed.

  • Délai typique: 1–1.5 min
  • Crédits: 5 crédits en 2K · 6 crédits en 4K
  • Traitement: asynchrone, polling
  • Limites: 600 requêtes/min
  • Authentification: Clé Bearer

Chaque chiffre sur cette page provient de la documentation de l'API Photta · vérifié

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
Exemple de sortie

En un coup d'œil

En un coup d'œil

Endpoint
POST /api/v1/tryon/apparel
Authentification
Clé API Bearer
Traitement
Asynchrone — interrogez l'endpoint de statut par polling
Délai typique
1–1.5 min
Crédits
5 crédits en 2K · 6 crédits en 4K
Rapports d'aspect
3:4 · 1:1 · 4:3 · 2:3 · 3:2 · 4:5 · 5:4 · 9:16 · 16:9 · 21:9
Limites d'entrée
Jusqu'à 10 Mo par image ; JPEG, PNG, WebP
Idempotent
Oui

Requête et réponse

Requête

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 / Terminé

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

Paramètres de requête

product_type

Type: stringRequis

Type of garment.

Valeurs: topbottomtop_and_bottomone_piece
product_images

Type: array[string]Requis

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

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

Type: string

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

top_back_image

Type: string

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

bottom_image

Type: string

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

bottom_back_image

Type: string

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

mannequin_id

Type: stringRequis

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

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

Valeurs: whitelight_graygraycharcoalblackbeigecreamsand
pose_id

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

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

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

Type: string

Output resolution.

= 2K

Valeurs: 2K4K
aspect_ratio

Type: string

Output aspect ratio.

= 3:4

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

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

Valeurs: XSSMLXLXXLpetiteslimregularathleticcurvyplus_size
expression

Type: string

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

= neutral

Valeurs: neutralsoft_smileconfidentseriousrelaxedhappysmiling
footwear_url

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

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

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

Type: string

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

bottom_category

Type: string

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

length

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

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

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

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

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

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

Erreurs

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.

Limites

  • 600 requêtes par minute par compte (Fenêtre fixe ; la limite est identique sur tous les forfaits)
  • Une 429 renvoie Retry-After: 30 secondes
  • Jusqu'à 10 Mo par image
  • Formats: JPEG, PNG, WebP
  • Lots simultanés par forfait: Free 1 · Hobby 2 · Seller 3 · Brand 4 · Studio 6
  • Polling uniquement — l'API n'envoie aucun webhook.

5 étapes, une seule photo de produit

Choisissez un mannequin, soumettez le job, effectuez le polling jusqu'à la fin, téléchargez le résultat.

  1. Étape 1

    Générer une clé API

    Inscrivez-vous sur ai.photta.app, ouvrez l'onglet Developers, cliquez sur Generate API key. Les clés de production commencent par `photta_live_`. Placez la clé dans `PHOTTA_API_KEY` — ne la committez jamais.

  2. Étape 2

    Choisir un mannequin

    GET `/api/v1/mannequins` pour lister les modèles disponibles et récupérer l'identifiant souhaité. Les poses ont été retirées le 2026-08-10 : chaque prise de vue est un plan plein pied de face, face à la caméra, il n'y a donc rien d'autre à choisir.

  3. Étape 3

    Envoyer le job de try-on en POST

    Envoyez une requête POST à `/api/v1/tryon/apparel` avec `product_type`, `product_images`, `mannequin_id` et les options `resolution` et `aspect_ratio`. L'API renvoie 202 Accepted avec un identifiant de génération.

  4. Étape 4

    Effectuer le polling jusqu'à la fin du job

    GET `/api/v1/tryon/apparel/:id` toutes les 3 secondes. Lorsque `data.status` passe à `completed`, le payload contient `output_url` et `thumbnail_url`. Définissez une limite haute pour éviter qu'un job bloqué ne suspende indéfiniment votre requête.

  5. Étape 5

    Télécharger et persister

    Récupérez les octets depuis `output_url` et stockez-les dans votre propre stockage d'objets. L'URL CDN est stable, mais votre produit ne doit pas en dépendre pour l'affichage.

Questions que les développeurs se posent avant de déployer le try-on de vêtements

Qu'est-ce que l'API de virtual try-on de Photta ?

Un endpoint REST qui prend en entrée une photo de produit à plat (flat-lay) ainsi qu'un mannequin ID, et renvoie une image photoréaliste portée sur modèle. Même pipeline que l'application grand public de Photta. 4 types de produits sont pris en charge : haut, bas, haut+bas, une-pièce.

Combien coûte chaque appel ?

5 crédits pour un résultat en 2K, 6 crédits pour la 4K. Les crédits sont inclus dans votre abonnement et peuvent être rechargés. Les générations échouées ne coûtent aucun crédit — elles sont remboursées.

Combien de temps prend une génération ?

La finalisation prend généralement 1.5 à 4 minutes, mesurée de bout en bout. La requête POST renvoie un identifiant de génération en moins d'une seconde ; le traitement GPU s'exécute en tâche de fond pendant votre polling.

Quels types de produits sont pris en charge ?

Quatre : `top`, `bottom`, `top_and_bottom`, `one_piece`. Chacun attend une structure spécifique pour `product_images` — par exemple, `top_and_bottom` nécessite les URL `top_image` et `bottom_image`.

Puis-je utiliser mon propre mannequin ?

Oui. Uploadez une photo de mannequin avec `POST /api/v1/mannequins` ou générez un nouveau mannequin IA via `POST /api/v1/mannequins/generate`. L'identifiant renvoyé s'injecte directement dans la requête de try-on.

Comment effectuer le polling pour obtenir le résultat ?

GET `/api/v1/tryon/apparel/:id` toutes les 3 à 5 secondes jusqu'à ce que `data.status` passe à `completed` ou `failed`. Fixez une limite haute sur les tentatives — 120 × 3s couvre largement la fenêtre documentée.

Fonctionnalités associées

Chaque chiffre sur cette page provient de la documentation de l'API Photta · vérifié

Testez l'API en cinq minutes

Générez une clé d'API Photta, collez le snippet cURL ci-dessus, et vous obtiendrez votre première photo portée sur modèle avant même que le café ait fini de couler.

  • 1–1.5 min
  • 5 crédits en 2K · 6 crédits en 4K
  • asynchrone, polling
  • 600 requêtes/min
  • Clé Bearer