Funcionalidade · Roupas

API de try-on virtual para roupas

Em uma frase

A API de try-on virtual do Photta recebe uma imagem flat-lay de roupa e um ID de manequim e retorna uma foto de modelo em 2K ou 4K. Envie o job via POST, faça polling a cada 3–5 segundos, baixe quando o status for completed.

  • Tempo típico: 1.5–4 min
  • Credits: 5 credits em 2K · 6 credits em 4K
  • Processamento: assíncrono, polling
  • Limites: 600 requisições/min
  • Autenticação: Chave Bearer

Todos os números nesta página vêm de a documentação da API da Photta · verificado

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",
  "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
Exemplo de saída

Visão geral

Visão geral

Endpoint
POST /api/v1/tryon/apparel
Autenticação
API key Bearer
Processamento
Assíncrono — faça polling no endpoint de status
Tempo típico
1.5–4 min
Credits
5 credits em 2K · 6 credits em 4K
Proporções de tela
3:4 · 1:1 · 4:3 · 2:3 · 3:2 · 4:5 · 5:4 · 9:16 · 16:9 · 21:9
Limites de entrada
Até 10 MB por imagem; JPEG, PNG, WebP
Idempotente
Não

Requisição e resposta

Requisição

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",
  "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 / Concluído

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

Parâmetros da requisição

product_type

Tipo: stringObrigatório

Type of garment.

Valores: topbottomtop_and_bottomone_piece
product_images

Tipo: array[string]Obrigatório

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

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. Sending one asks for a back shot, exactly as product_back_image does.

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. Sending one asks for a back shot, exactly as product_back_image does.

mannequin_id

Tipo: stringObrigatório

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

background_color

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

Valores: whitelight_graygraycharcoalblackbeigecreamsand
pose_id

Tipo: string

RETIRED 2026-08-10 — accepted and ignored. Poses were removed from apparel try-on; every generation is now a straight, relaxed, camera-facing full-body shot (the old FullBody stance). Sending it returns Deprecation and Sunset headers. Deleted 2027-02-10 — stop sending it.

background

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

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

Tipo: string

Output resolution.

= 2K

Valores: 2K4K
aspect_ratio

Tipo: string

Output aspect ratio.

= 3:4

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

Tipo: string

Body size of the mannequin.

= M

Valores: XSSMLXLXXL
expression

Tipo: string

Facial expression.

= neutral

Valores: neutralhappyserioussmiling
footwear_url

Tipo: string

URL or base64 of a custom footwear image. Every generation is a full-body shot, so supplied footwear is staged and worn.

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.

Erros

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 (500), or a check your request needs could not run right now (503, e.g. moderation_unavailable). Retry later with backoff.

Limites

  • 600 requisições por minuto por conta (Janela fixa; o limite é o mesmo em todos os planos)
  • Um 429 retorna Retry-After: 30 segundos
  • Até 10 MB por imagem
  • Formatos: JPEG, PNG, WebP
  • Batches concorrentes por plano: Free 1 · Hobby 2 · Seller 3 · Brand 4 · Studio 6
  • Apenas polling — a API não envia webhooks.

Cinco etapas, uma foto de produto

Escolha um manequim, envie o job, faça polling até concluir, baixe o resultado.

  1. Passo 1

    Gere uma chave de API

    Cadastre-se em ai.photta.app, abra a aba Desenvolvedores e clique em Gerar chave de API. As chaves ativas começam com `photta_live_`. Coloque a chave em `PHOTTA_API_KEY` — nunca faça commit dela.

  2. Passo 2

    Escolha um manequim

    GET `/api/v1/mannequins` para listar os modelos disponíveis e pegar o ID desejado. As poses foram descontinuadas em 2026-08-10: cada foto é de corpo inteiro, reta e voltada para a câmera, portanto não há mais nada para escolher.

  3. Passo 3

    Faça o POST do job de try-on

    Envie um POST para `/api/v1/tryon/apparel` com `product_type`, `product_images`, `mannequin_id` e os opcionais `resolution` e `aspect_ratio`. A API retorna 202 Accepted com um ID de geração.

  4. Passo 4

    Faça polling até o job ser concluído

    GET `/api/v1/tryon/apparel/:id` a cada 3 segundos. Quando `data.status` mudar para `completed`, o payload incluirá `output_url` e `thumbnail_url`. Defina um limite máximo para que um job travado não prenda sua requisição.

  5. Passo 5

    Baixe e mantenha os dados persistidos

    Faça o fetch dos bytes de `output_url` e armazene-os no seu próprio object storage. A URL da CDN é estável, mas seu produto não deve depender dela para renderização.

Dúvidas frequentes de desenvolvedores antes de colocar o try-on de roupas em produção

O que é a API de virtual try-on da Photta?

Um endpoint REST que recebe uma foto do produto em flat-lay e um ID de manequim, retornando uma imagem fotorrealista no modelo. O mesmo pipeline do app para consumidores da Photta. Suporta quatro tipos de produto: top, bottom, top+bottom e one-piece.

Quanto custa por chamada?

5 credits para um resultado em 2K, 6 credits para 4K. Os credits vêm na sua assinatura e podem ser recarregados. Gerações que falham não gastam credits — são reembolsadas.

Quanto tempo leva uma geração?

A conclusão típica leva de 1.5 a 4 minutos, medidos de ponta a ponta. O POST retorna um ID de geração em menos de um segundo; o processamento em GPU acontece em segundo plano enquanto você faz o polling.

Quais tipos de produto são suportados?

Quatro: `top`, `bottom`, `top_and_bottom`, `one_piece`. Cada um exige um formato diferente de `product_images` — por exemplo, `top_and_bottom` requer URLs tanto para `top_image` quanto para `bottom_image`.

Posso usar meu próprio manequim?

Sim. Faça o upload de uma foto de manequim com `POST /api/v1/mannequins` ou gere um novo manequim por IA com `POST /api/v1/mannequins/generate`. O ID retornado é inserido diretamente na requisição de try-on.

Como faço o polling pelo resultado?

GET `/api/v1/tryon/apparel/:id` a cada 3 a 5 segundos até que `data.status` seja `completed` ou `failed`. Defina um limite máximo de tentativas — 120 × 3s cobre a janela documentada com margem de sobra.

Recursos relacionados

Todos os números nesta página vêm de a documentação da API da Photta · verificado

Experimente a API em cinco minutos

Gere uma chave de API do Photta, cole o snippet de cURL acima e você terá sua primeira imagem com modelo antes que o café termine de passar.

  • 1.5–4 min
  • 5 credits em 2K · 6 credits em 4K
  • assíncrono, polling
  • 600 requisições/min
  • Chave Bearer