Capability · Apparel

Virtuel try-on API til tøj

I én sætning

Phottas virtuelle try-on API tager et flat-lay tøjbillede, et mannequin-ID og et pose-ID og returnerer et 2K- eller 4K-foto på en model. POST jobbet, poll hvert 3.–5. sekund, download, når status er completed.

  • Typisk tid: 1.5–4 min
  • Credits: 5 credits ved 2K · 6 credits ved 4K
  • Behandling: async, polling
  • Grænser: 600 requests/min
  • Autentifikation: Bearer key

Hvert tal på denne side stammer fra Photta API-dokumentationen · tjekket

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
Eksempel på output

Kort fortalt

Kort fortalt

Endpoint
POST /api/v1/tryon/apparel
Autentifikation
Bearer API-nøgle
Behandling
Asynkron — poll status-endpointet
Typisk tid
1.5–4 min
Credits
5 credits ved 2K · 6 credits ved 4K
Billedformater
3:4 · 1:1 · 4:3 · 9:16 · 16:9
Inputgrænser
Op til 10 MB pr. billede; JPEG, PNG, WebP
Idempotent
Nej

Request og 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": "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 / Completed

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

Request-parametre

product_type

Type: stringPåkrævet

Type of garment.

Værdier: topbottomtop_and_bottomone_piece
product_images

Type: array[string]Påkrævet

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: stringPåkrævet

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

pose_id

Type: stringPåkrævet

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

Værdier: 2K4K
aspect_ratio

Type: string

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

= 3:4

Værdier: 3:41:14:39:1616:9
body_size

Type: string

Body size of the mannequin.

= M

Værdier: XSSMLXLXXL
expression

Type: string

Facial expression.

= neutral

Værdier: 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.

Fejl

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.

Grænser

  • 600 anmodninger i minuttet pr. API-nøgle (Fast vindue; grænsen er den samme på alle planer)
  • En 429 indeholder Retry-After: 30 sekunder
  • Op til 10 MB pr. billede
  • Formater: JPEG, PNG, WebP
  • Samtidige batches pr. plan: Free 1 · Hobby 2 · Seller 3 · Brand 4 · Studio 6
  • Kun polling — API'et sender ingen webhooks.

Fem trin, ét produktfoto

Vælg en mannequin, indsend jobbet, poll indtil det er færdigt, download resultatet.

  1. Trin 1

    Generér en API-nøgle

    Opret en konto på ai.photta.app, åbn fanen Developers, klik på Generate API key. Live-nøgler starter med `photta_live_`. Gem nøglen i `PHOTTA_API_KEY` — commit den aldrig.

  2. Trin 2

    Vælg en mannequin og en positur

    GET `/api/v1/mannequins` for at se tilgængelige muligheder. GET `/api/v1/poses` for beskæringen. Begge ID'er sendes med i try-on-requestet.

  3. Trin 3

    POST try-on-jobbet

    Send en POST til `/api/v1/tryon/apparel` med `product_type`, `product_images`, `mannequin_id`, `pose_id` samt valgfri `resolution` og `aspect_ratio`. API'et returnerer 202 Accepted med et generations-ID.

  4. Trin 4

    Poll indtil jobbet er færdigt

    GET `/api/v1/tryon/apparel/:id` hvert 3. sekund. Når `data.status` skifter til `completed`, indeholder payloaden `output_url` og `thumbnail_url`. Sæt en øvre grænse, så et fastlåst job ikke blokerer dit request.

  5. Trin 5

    Download og gem

    Hent bytes fra `output_url` og gem dem i din egen object storage. CDN-URL'en er stabil, men dit produkt bør ikke afhænge af den til rendering.

Spørgsmål udviklere stiller, før de deployer try-on til tøj

Hvad er Phottas virtuelle try-on-API?

Et REST-endpoint, der tager et flat-lay-produktbillede og et mannequin-ID og returnerer et fotorealistisk billede på en model. Samme pipeline som Phottas forbruger-app. Fire produkttyper understøttes: top, underdel, top+underdel, heldragt.

Hvad koster det pr. kald?

5 credits for et 2K-resultat, 6 credits for 4K. Credits følger med dit abonnement og kan tankes op. Mislykkede generationer koster ikke credits — de refunderes.

Hvor lang tid tager en generering?

Typisk færdiggørelsestid er 1,5 til 4 minutter, målt end-to-end. POST returnerer et generations-ID på under et sekund; GPU-arbejdet foregår i baggrunden, mens du poller.

Hvilke produkttyper understøttes?

Fire: `top`, `bottom`, `top_and_bottom`, `one_piece`. Hver type forventer en specifik struktur for `product_images` — for eksempel kræver `top_and_bottom` både `top_image`- og `bottom_image`-URL'er.

Kan jeg bruge min egen mannequin?

Ja. Upload et mannequin-foto med `POST /api/v1/mannequins`, eller generér en ny AI-mannequin med `POST /api/v1/mannequins/generate`. Det returnerede ID kan indsættes direkte i try-on-requestet.

Hvordan poller jeg efter resultatet?

GET `/api/v1/tryon/apparel/:id` hvert 3. til 5. sekund, indtil `data.status` er `completed` eller `failed`. Sæt en øvre grænse for antal forsøg — 120 × 3s dækker det dokumenterede tidsvindue med god margin.

Relaterede funktioner

Hvert tal på denne side stammer fra Photta API-dokumentationen · tjekket

Prøv API'et på fem minutter

Generér en Photta API-nøgle, indsæt cURL-kodestykket ovenfor, og du har dit første billede på en model, før kaffen er færdigbrygget.

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