> ## Documentation Index
> Fetch the complete documentation index at: https://docs.selektable.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Create a generation

> Starts an asynchronous AI visualization. Returns `202 Accepted` with a `processing` generation. Supply an `Idempotency-Key` header to safely retry.

Starts an asynchronous AI visualization from a customer photo plus 1–3 products. Returns `202 Accepted` with a `processing` generation.

Learn the outcome via [webhooks](/api-reference/webhooks) (recommended) or by [polling the generation](/api-reference/endpoints/generations/retrieve).

Supply an [`Idempotency-Key`](/api-reference/idempotency) header to safely retry on network failures.


## OpenAPI

````yaml POST /v1/generations
openapi: 3.1.0
info:
  title: Selektable API
  version: 1.0.0
  description: >-
    Generate AI product visualizations from a customer photo. Two modes are
    supported: `virtual-try-on` (fashion) and `room-visualizer` (interior).
    Generations are asynchronous: subscribe a webhook endpoint (recommended) or
    poll the generation.
  contact:
    name: Selektable Support
    url: https://selektable.com
servers:
  - url: https://app.selektable.com
    description: Production
security:
  - bearerAuth: []
tags:
  - name: Generations
    description: Create and retrieve AI visualizations
  - name: Webhook Endpoints
    description: Manage outgoing webhook destinations
paths:
  /v1/generations:
    post:
      tags:
        - Generations
      summary: Create a generation
      description: >-
        Starts an asynchronous AI visualization. Returns `202 Accepted` with a
        `processing` generation. Supply an `Idempotency-Key` header to safely
        retry.
      parameters:
        - name: Idempotency-Key
          in: header
          required: false
          schema:
            type: string
          description: Unique key to make creation idempotent.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreateGenerationRequest'
      responses:
        '200':
          description: Idempotent replay — existing generation returned
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Generation'
        '202':
          description: Generation queued
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Generation'
        '400':
          $ref: '#/components/responses/Error'
        '401':
          $ref: '#/components/responses/Error'
        '403':
          $ref: '#/components/responses/Error'
        '429':
          $ref: '#/components/responses/Error'
components:
  schemas:
    CreateGenerationRequest:
      type: object
      required:
        - mode
        - image
        - products
      properties:
        mode:
          type: string
          enum:
            - virtual-try-on
            - room-visualizer
          description: '`virtual-try-on` = fashion; `room-visualizer` = interior staging.'
        image:
          type: string
          description: >-
            Customer photo: an https URL or a `data:image/*;base64,...` URI
            (≤10MB).
        products:
          type: array
          minItems: 1
          maxItems: 3
          items:
            $ref: '#/components/schemas/Product'
        hint:
          type: string
          maxLength: 500
          description: Optional styling guidance.
        imageSize:
          type: string
          enum:
            - 1K
            - 2K
            - 4K
          default: 1K
          description: Output resolution. Consumes 1/2/3 credits respectively.
        metadata:
          type: object
          additionalProperties:
            type: string
          description: Up to 40 string key/values, echoed back on the generation.
    Generation:
      type: object
      properties:
        id:
          type: string
          example: agen_abc123
        object:
          type: string
          enum:
            - generation
        status:
          type: string
          enum:
            - processing
            - complete
            - failed
        mode:
          type: string
          enum:
            - virtual-try-on
            - room-visualizer
        imageSize:
          type: string
          enum:
            - 1K
            - 2K
            - 4K
        imageUrl:
          type:
            - string
            - 'null'
          format: uri
          description: >-
            Permanent CDN URL to the original render at the requested
            `imageSize` (1K/2K/4K). Safe to store and embed.
        imageVariants:
          type:
            - object
            - 'null'
          description: >-
            Permanent CDN URLs to resized JPEG/WebP variants of `imageUrl`,
            served by Cloudflare Image Transformations. Use a variant instead of
            the original when you need a smaller payload (emails, lists,
            mobile). `null` until `status` is `complete`.
          properties:
            list:
              $ref: '#/components/schemas/ImageVariant'
              description: 200px wide. Tables, recent-renders strips, dense grids.
            card:
              $ref: '#/components/schemas/ImageVariant'
              description: Email embeds, product cards, cart drawers, mobile widths.
            detail:
              $ref: '#/components/schemas/ImageVariant'
              description: PDP hero, full-screen overlay, primary surface.
        products:
          type: array
          items:
            $ref: '#/components/schemas/Product'
        hint:
          type:
            - string
            - 'null'
        error:
          type:
            - object
            - 'null'
          properties:
            code:
              type: string
            message:
              type: string
        metadata:
          type:
            - object
            - 'null'
          additionalProperties:
            type: string
        createdAt:
          type: string
          format: date-time
        completedAt:
          type:
            - string
            - 'null'
          format: date-time
    Product:
      type: object
      required:
        - productId
        - productTitle
        - imageUrl
      properties:
        productId:
          oneOf:
            - type: string
            - type: number
        productTitle:
          type: string
        imageUrl:
          type: string
          format: uri
        productUrl:
          type: string
          format: uri
        dimensions:
          type: object
          description: Optional real-world dimensions (improves interior scale accuracy).
    ImageVariant:
      type: object
      required:
        - url
        - width
      properties:
        url:
          type: string
          format: uri
          description: Permanent, CDN-cached URL for this variant.
        width:
          type: integer
          description: Maximum width in pixels. Height scales proportionally.
    Error:
      type: object
      properties:
        error:
          type: object
          properties:
            type:
              type: string
              enum:
                - authentication_error
                - authorization_error
                - invalid_request_error
                - rate_limit_error
                - not_found_error
                - conflict_error
                - api_error
            code:
              type: string
            message:
              type: string
            param:
              type: string
  responses:
    Error:
      description: Error response
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      description: >-
        Your Selektable API key (`selektable_...`), sent as `Authorization:
        Bearer <key>`.

````