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

# Generate Media Asset

> Starts an AI media generation job billed from the account's balance. Generation is asynchronous — poll `GET /media/{id}` until the asset is `ready`, then use `file.id` anywhere attachments are accepted.



## OpenAPI

````yaml /openapi/api-v1-native.yml post /media/generate
openapi: 3.1.0
info:
  title: Whop API
  description: >-
    Hand-written V1 endpoints. Merged into the GraphqlRestProxy-generated schema
    at build time.
  version: v1
servers:
  - url: https://{defaultHost}
    variables:
      defaultHost:
        default: api.whop.com/api/v1
security: []
paths:
  /media/generate:
    post:
      tags:
        - Media
      summary: Generate Media Asset
      description: >-
        Starts an AI media generation job billed from the account's balance.
        Generation is asynchronous — poll `GET /media/{id}` until the asset is
        `ready`, then use `file.id` anywhere attachments are accepted.
      operationId: generateMediaAsset
      parameters: []
      requestBody:
        content:
          application/json:
            schema:
              type: object
              properties:
                account_id:
                  type: string
                  description: >-
                    Account ID, prefixed `biz_`. Defaults to the account the API
                    key belongs to.
                type:
                  type: string
                  enum:
                    - video
                    - image
                  description: The kind of media to generate.
                prompt:
                  type: string
                  description: What to generate. Up to 2,000 characters.
                reference_media:
                  type: array
                  items:
                    type: string
                  description: >-
                    Optional reference image file IDs (`file_` prefixed), up to
                    4. For video the first reference seeds the opening frame.
                duration_seconds:
                  type: integer
                  enum:
                    - 5
                    - 10
                    - 15
                  description: Video length in seconds. Video only; defaults to 5.
                resolution:
                  type: string
                  enum:
                    - 480p
                    - 720p
                    - 1080p
                    - 4k
                  description: >-
                    Video resolution. Video only; defaults to `1080p`. `1080p`
                    is not supported by Seedance 2.0 Fast or Mini; `4k` is only
                    supported by Seedance 2.0.
              required:
                - type
                - prompt
        required: true
      responses:
        '201':
          description: Generation started.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/MediaAsset'
        '400':
          description: Invalid generation parameters.
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: object
                    properties:
                      type:
                        type: string
                      message:
                        type: string
                    required:
                      - type
                      - message
                required:
                  - error
        '401':
          $ref: '#/components/responses/Unauthorized'
          description: Missing or invalid authentication.
        '402':
          description: Insufficient balance.
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: object
                    properties:
                      type:
                        type: string
                        enum:
                          - payment_required
                      message:
                        type: string
                      deposit_url:
                        type: string
                        description: >-
                          Hosted page where the account can deposit funds before
                          retrying.
                    required:
                      - type
                      - message
                      - deposit_url
                required:
                  - error
        '403':
          $ref: '#/components/responses/Forbidden'
          description: Missing the media:generate scope.
      security:
        - bearerAuth:
            - media:generate
components:
  schemas:
    MediaAsset:
      type: object
      properties:
        id:
          type: string
          description: Media asset ID, prefixed `media_`.
        media_type:
          type: string
          description: The kind of media this asset holds.
          enum:
            - video
            - image
          example: video
        source:
          type: string
          description: How the asset was created. Always `generated`.
          enum:
            - generated
          example: generated
        status:
          type: string
          description: >-
            Lifecycle state: `processing` while generation runs, `ready` when
            the file is available, `failed` when generation failed and the
            charge was refunded.
          enum:
            - processing
            - ready
            - failed
          example: processing
        amount_charged:
          type:
            - number
            - 'null'
          description: >-
            USD amount charged to the account's balance for this generation.
            `null` if the generation wasn't billed.
        currency:
          type: string
          description: Currency of `amount_charged`. Always `usd`.
        error_message:
          type:
            - string
            - 'null'
          description: Why generation failed. `null` unless status is `failed`.
        created_at:
          type: string
          description: ISO 8601 timestamp when the generation was requested.
        completed_at:
          type:
            - string
            - 'null'
          description: >-
            ISO 8601 timestamp when the asset reached a terminal state. `null`
            while `processing`.
        generation:
          $ref: '#/components/schemas/MediaAssetGeneration'
          description: The inputs the asset was generated from.
        file:
          description: >-
            The produced file, usable anywhere attachments are accepted. `null`
            until the asset is `ready`.
          oneOf:
            - $ref: '#/components/schemas/MediaAssetFile'
            - type: 'null'
      required:
        - id
        - media_type
        - source
        - status
        - amount_charged
        - currency
        - error_message
        - created_at
        - completed_at
        - generation
        - file
    MediaAssetGeneration:
      type: object
      properties:
        prompt:
          type: string
          description: What the asset was generated from.
        reference_media:
          type: array
          items:
            type: string
            description: >-
              Reference image file IDs (`file_` prefixed) supplied at generation
              time.
        duration_seconds:
          type:
            - number
            - 'null'
          description: Requested video length in seconds. `null` for images.
        resolution:
          type:
            - string
            - 'null'
          description: >-
            Requested video resolution. `null` for images. `1080p` is not
            supported by Seedance 2.0 Fast or Mini; `4k` is only supported by
            Seedance 2.0.
          enum:
            - 480p
            - 720p
            - 1080p
            - 4k
            - null
          example: 480p
      required:
        - prompt
        - reference_media
        - duration_seconds
        - resolution
    MediaAssetFile:
      type: object
      properties:
        id:
          type: string
          description: File ID, prefixed `file_`.
        url:
          type: string
          description: CDN URL for downloading the file.
      required:
        - id
        - url
    V1ErrorResponse:
      type: object
      properties:
        error:
          type: object
          properties:
            type:
              type: string
              description: Machine-readable error code.
            message:
              type: string
              description: Human-readable error message.
          required:
            - type
            - message
      required:
        - error
  responses:
    Unauthorized:
      description: Unauthorized
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/V1ErrorResponse'
    Forbidden:
      description: Forbidden
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/V1ErrorResponse'
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: auth-scheme
      description: >-
        An account API key, account scoped JWT, app API key, or user OAuth
        token.

````