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, un mannequin_id et un identifiant de pose, 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.5–4 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": "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
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.5–4 min
Crédits
5 crédits en 2K · 6 crédits en 4K
Rapports d'aspect
3:4 · 1:1 · 4:3 · 9:16 · 16:9
Limites d'entrée
Jusqu'à 10 Mo par image ; JPEG, PNG, WebP
Idempotent
Non

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

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

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

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. Auto-selected on back-facing poses when present.

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. Auto-selected on back-facing poses when present.

mannequin_id

Type: stringRequis

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

pose_id

Type: stringRequis

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

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

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

Type: string

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

= 2K

Valeurs: 2K4K
aspect_ratio

Type: string

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

= 3:4

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

Type: string

Body size of the mannequin.

= M

Valeurs: XSSMLXLXXL
expression

Type: string

Facial expression.

= neutral

Valeurs: neutralhappyserioussmiling
footwear_url

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

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

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

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

Limites

  • 600 requêtes par minute par clé API (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 et une pose

    GET `/api/v1/mannequins` pour lister les options disponibles. GET `/api/v1/poses` pour le cadrage. Les deux identifiants s'intègrent dans la requête de try-on.

  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`, `pose_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 credits pour un résultat en 2K, 6 credits pour la 4K. Les credits sont inclus dans votre abonnement et peuvent être rechargés. Les générations échouées ne coûtent aucun credit — 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.5–4 min
  • 5 crédits en 2K · 6 crédits en 4K
  • asynchrone, polling
  • 600 requêtes/min
  • Clé Bearer