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

# Create a generation

> Submits an idempotent image or video generation. Image-input modes accept only owner-scoped generated-library creation IDs.



## OpenAPI

````yaml /openapi.json post /api/v1/generations
openapi: 3.1.0
info:
  title: Porn Factory AI API
  version: 1.0.0
  description: >-
    Catalog-backed image and video generation with credit accounting, polling,
    and signed webhooks.
servers:
  - url: https://pornfactoryai.com
    description: Production
security:
  - bearerAuth: []
tags:
  - name: Catalog
    description: Generator-ready checkpoints and LoRAs
  - name: Credits
    description: Account credit balance
  - name: Generations
    description: Image and video request lifecycle
paths:
  /api/v1/generations:
    post:
      tags:
        - Generations
      summary: Create a generation
      description: >-
        Submits an idempotent image or video generation. Image-input modes
        accept only owner-scoped generated-library creation IDs.
      operationId: createGeneration
      parameters:
        - name: Idempotency-Key
          in: header
          required: true
          description: >-
            Stable key for this logical request. Reuse only with the exact same
            body.
          schema:
            type: string
            minLength: 1
            maxLength: 255
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/GenerationCreateRequest'
      responses:
        '202':
          description: Generation accepted
          headers:
            Location:
              description: Absolute poll URL for the request.
              schema:
                type: string
                format: uri
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Generation'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '402':
          $ref: '#/components/responses/InsufficientCredits'
        '403':
          $ref: '#/components/responses/Forbidden'
        '409':
          $ref: '#/components/responses/Conflict'
        '422':
          $ref: '#/components/responses/UnprocessableEntity'
        '429':
          $ref: '#/components/responses/RateLimited'
        '502':
          $ref: '#/components/responses/BadGateway'
        '503':
          $ref: '#/components/responses/ServiceUnavailable'
components:
  schemas:
    GenerationCreateRequest:
      type: object
      required:
        - mode
        - prompt
        - seed_mode
        - checkpoint
      properties:
        mode:
          $ref: '#/components/schemas/GenerationMode'
        prompt:
          type: string
          minLength: 1
        negative_prompt:
          type: string
        edit_instruction:
          type: string
        seed_mode:
          type: string
          enum:
            - random
            - custom
        seed:
          type: integer
          minimum: 0
          maximum: 1999999999
          description: Required when seed_mode is custom.
        checkpoint:
          $ref: '#/components/schemas/CheckpointSelection'
        loras:
          type: array
          maxItems: 4
          default: []
          items:
            $ref: '#/components/schemas/LoraSelection'
        source_creation_id:
          type: string
          format: uuid
          description: Required for image_to_image, image_edit, and image_to_video.
        reference_creation_id:
          type: string
          format: uuid
        width:
          type: number
          default: 768
        height:
          type: number
          default: 1024
        steps:
          type: number
          default: 8
        cfg_scale:
          type: number
          default: 1
        duration_seconds:
          type: number
          default: 5
        quality:
          type: string
          default: medium
        fps:
          type: number
          default: 30
        audio_enabled:
          type: boolean
          default: false
        audio_prompt:
          type: string
        webhook_url:
          type: string
          format: uri
          pattern: ^https://
      additionalProperties: false
    Generation:
      type: object
      required:
        - object
        - request_id
        - status
        - poll_url
        - credits
        - created_at
        - updated_at
      properties:
        object:
          type: string
          const: generation
        request_id:
          type: string
          pattern: ^req_
        status:
          type: string
          enum:
            - IN_QUEUE
            - IN_PROGRESS
            - COMPLETED
            - FAILED
        kind:
          type:
            - string
            - 'null'
          enum:
            - image
            - video
            - null
        poll_url:
          type: string
          format: uri
        progress:
          type: number
        credits:
          type: object
          required:
            - charged
          properties:
            charged:
              type: number
        output:
          type: object
          properties:
            media_url:
              type:
                - string
                - 'null'
              format: uri
            preview_url:
              type:
                - string
                - 'null'
              format: uri
        error:
          type: object
          properties:
            code:
              type: string
            message:
              type: string
        created_at:
          type: string
          format: date-time
        updated_at:
          type: string
          format: date-time
        completed_at:
          type:
            - string
            - 'null'
          format: date-time
    GenerationMode:
      type: string
      enum:
        - text_to_image
        - image_to_image
        - image_edit
        - text_to_video
        - image_to_video
    CheckpointSelection:
      type: object
      additionalProperties: false
      required:
        - model_id
        - version_id
      properties:
        model_id:
          type: string
        version_id:
          type: string
    LoraSelection:
      type: object
      additionalProperties: false
      required:
        - model_id
        - version_id
      properties:
        model_id:
          type: string
        version_id:
          type: string
        strength:
          type: number
          minimum: 0
          maximum: 2
          default: 1
    Error:
      type: object
      required:
        - error
        - code
      properties:
        error:
          type: string
        code:
          type: string
        available_credits:
          type: number
        required_credits:
          type: number
  responses:
    BadRequest:
      description: Invalid request
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
    Unauthorized:
      description: Missing or invalid API key
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
    InsufficientCredits:
      description: Insufficient credits
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
    Forbidden:
      description: Missing scope or suspended account
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
    Conflict:
      description: Idempotency conflict
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
    UnprocessableEntity:
      description: Unsupported input
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
    RateLimited:
      description: Rate limit exceeded
      headers:
        X-RateLimit-Limit:
          schema:
            type: integer
        X-RateLimit-Remaining:
          schema:
            type: integer
        X-RateLimit-Reset:
          schema:
            type: integer
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
    BadGateway:
      description: Generation submission is temporarily unavailable
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
    ServiceUnavailable:
      description: Temporary platform failure
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: pfai_ API key
      description: Create a scoped key at https://pornfactoryai.com/account?tab=developer

````