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

# Generate Media

> The generations endpoint lets users generate media based on various parameters such as aspect ratio, model, prompt etc. The response will return a generation ID for each request, which can be used to track the status and view generated media.

<Info>
  Start using `mode` in character object while generating images using character.

  <Warning>
    `weight` and `enable_facelock` are deprecated and will be removed in the future.
  </Warning>

  <br />

  Example:

  ```json theme={null}
  [
      {
          .
          .
          "character": {
              "character_id": "char_001",
              "mode": "balanced"
          }
          .
          .
      }
  ]
  ```
</Info>

<Tip>
  Added support for `Video Anyone` generation

  <Warning>
    Any attempt to produce NSFW, violent, or public figure content will result in permanent account termination.
  </Warning>

  You can use either a generated image's media\_id or an uploaded image asset's asset\_id as the input image identifier `media_id` for video generation, eliminating the need to re-upload images as assets.

  ```json Example request theme={null}
  [
      {
          "video_anyone": {
              "media_id": "ast_xxxxxxxx",
              "prompt": "A person riding a bicycle",
              "duration": 5
          }
      }
  ]
  ```
</Tip>

<Info>
  For `video_anyone` generation make sure that input image meets the following conditions to avoid generation failure:

  1. Input image aspect ratio should be either `3:5` or `5:3`.
  2. Maximum characters permitted for `prompt` is 500 only.
</Info>

<br />

<Tip>
  When using the generation array, ensure that each object contains only one of the following properties: `segment`, `style`, `model`, `true_touch`, `narrator` or `video_anyone`. These properties have a priority order as follows:

  1. `segment`
  2. `style`
  3. `model`
  4. `true_touch`
  5. `narrator`
  6. `video_anyone`

  If multiple properties are provided, the one with the highest priority will be used.
</Tip>

<Tip>
  The `narrator` can be generated either by using a script paired with a voice(List all the available voices using `GET /pub/v1/voices` endpoint) or by utilizing an existing audio asset.
</Tip>

<Info>
  `segment`, `true_touch`, `narrator` and `video_anyone` generations only acknowledge parameters that are passed within their own objects.
</Info>

<Info>
  For `narrator` generation make sure that video asset meets the following conditions to avoid generation failure:

  1. The maximum supported frame rate for a video asset is 30 FPS, calculated by dividing the total number of frames by the total duration.
  2. Maximum height and width of the video asset should be `1080` and `1920` respectively.
</Info>


## OpenAPI

````yaml post /pub/v1/generations
openapi: 3.0.2
info:
  description: >-
    The Affogato API section provides a comprehensive set of APIs that allow you
    to create high-quality media content using textual and graphical inputs. By
    utilizing the features provided in this section, users can easily generate
    engaging visuals and media assets.You need an API key to use these APIs. To
    get your personal key, log in to Affogato, head to the account page at
    [Affogato](https://affogato.ai/account) and hit generate API key. Add this
    key as an X-API-Key header in the requests that you send.
  title: Affogato API
  version: '1.0'
servers: []
security: []
tags:
  - description: >-
      The Generation section allows users to create, view, and delete images on
      Rendernet.
    name: Generation
  - description: >-
      Explore all available resources that can be used for generating images on
      Rendernet. With this section, users can easily access key details about
      the resources at their disposal.
    name: Resources
  - description: Upload / Get information about assets that can be used for generation.
    name: Assets
paths:
  /pub/v1/generations:
    post:
      tags:
        - Generation
      summary: Generate media
      description: >-
        The generations endpoint lets users generate media based on various
        parameters such as aspect ratio, model, prompt etc. The response will
        return a generation ID for each request, which can be used to track the
        status and view generated media.
      parameters:
        - description: >-
            API key needed to access our public endpoints. You can find yours
            under the 'Account' section of the website
          required: true
          schema:
            type: string
            title: X-API-KEY
            description: >-
              API key needed to access our public endpoints. You can find yours
              under the 'Account' section of the website
          name: X-API-KEY
          in: header
      requestBody:
        content:
          application/json:
            schema:
              items:
                $ref: '#/components/schemas/GenerationRequest'
              type: array
      responses:
        '201':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/GenerationSuccessResponse'
          description: A list of submitted generation requests
components:
  schemas:
    GenerationRequest:
      properties:
        aspect_ratio:
          description: The aspect ratio of the image for the generation
          enum:
            - '1:1'
            - '2:3'
            - '3:2'
            - '4:5'
            - '16:9'
            - '9:16'
          example: '1:1'
          type: string
        batch_size:
          description: >-
            The batch size of the generation (Max permissible value depends on
            your subscription plan). Visit [RenderNet
            pricing](https://app.rendernet.ai/pricing) for more details
          example: 1
          type: integer
        cfg_scale:
          description: >-
            AI guidance for this generation. Higher the value, the output will
            be closer to the prompt (but may result in distorted images after a
            point)
          example: 7
          maximum: 12
          minimum: 4
          type: number
        character:
          $ref: '#/components/schemas/Character'
          description: >-
            If you want to create images of a character, use the character’s
            name in the positive prompt. Example: {character_name} riding a bike
        control_net:
          $ref: '#/components/schemas/ControlNet'
          description: >-
            The control net(pose control) for the generation if you want to use
            (optional)
        facelock:
          $ref: '#/components/schemas/Facelock'
          description: >-
            The face you want to restore for the generation if you want to use
            (optional)
        loras:
          description: >-
            Query the list resources endpoint `GET /pub/v1/loras` to view all
            available LoRAs. You can add multiple LoRAs to a single generation.
            Make sure your LoRAs have the same base model (SD 1.5 / SDXL) as
            your selected style/model.
          items:
            $ref: '#/components/schemas/Lora'
          type: array
        model:
          description: >-
            Query the list models endpoint `GET /pub/v1/models` to view all
            available models.
          example: JuggernautXL
          type: string
        narrator:
          $ref: '#/components/schemas/Narrator'
          description: >-
            For Narrator generation, pass either `script` or `audio_asset_id`
            along with other required details in `narrator` payload. 
        prompt:
          $ref: '#/components/schemas/Prompt'
          description: The prompt for the generation
        quality:
          description: The quality of the image for the generation (Case Sensitive)
          enum:
            - Plus
            - Regular
          example: Plus
          type: string
        sampler:
          description: The sampler you want to use for the generation (Case Sensitive)
          enum:
            - DPM++ 2M Karras
            - DPM++ 2M SDE Karras
            - DPM++ 2S a Karras
            - DPM++ SDE
            - DPM++ SDE Karras
            - Euler a
          example: DPM++ 2M Karras
          type: string
        seed:
          description: >-
            The seed for the generation (randomized if you don't want to use a
            seed)
          example: 1234
          type: integer
        segment:
          $ref: '#/components/schemas/Segment'
          description: Changes the input asset image based on the find and replace prompts
        steps:
          description: The number of steps you want AI to take for the generation
          example: 20
          maximum: 30
          minimum: 10
          type: integer
        style:
          description: >-
            Query the list styles endpoint `GET /pub/v1/styles` to view all
            available styles.
          example: Bokeh
          type: string
        style_detail:
          $ref: '#/components/schemas/StyleDetail'
          description: >-
            Query the list styles endpoint `GET /pub/v1/styles` to view all
            available styles.
        true_touch:
          $ref: '#/components/schemas/TrueTouch'
          description: Enhances and upscales the input image passed in the asset_id
        video_anyone:
          $ref: '#/components/schemas/VideoAnyone'
          description: Convert image to video seamlessly.
      type: object
    GenerationSuccessResponse:
      properties:
        data:
          $ref: '#/components/schemas/GenerationResponse'
          type: object
        err:
          description: The error if the request was not successful
          type: object
      type: object
    Character:
      type: object
      properties:
        character_id:
          description: >-
            ID of the character. You can get the details of characters using
            `GET /pub/v1/characters` endpoint or else you can create one using
            `POST /pub/v1/characters`
          example: chr_01
          type: string
        weight:
          description: This parameter is deprecated, use just mode instead
          example: 0.6
          type: number
          minimum: 0.1
          maximum: 1
          deprecated: true
        enable_facelock:
          description: This parameter is deprecated, use just mode instead
          example: true
          type: boolean
          deprecated: true
        mode:
          description: |-
            The mode of the character. 
            - `flexible` - Ideal for stylized characters and image generations. 
            - `balanced` - Ideal for creating realistic images and more. 
            - `strong` - Character similarity is most important.
          example: balanced
          enum:
            - flexible
            - balanced
            - strong
          type: string
      required:
        - character_id
        - mode
    ControlNet:
      type: object
      properties:
        asset_id:
          description: >-
            Upload a reference image using the `POST /pub/v1/assets/upload`
            endpoint . Pass the asset id in the payload to use the asset as a
            reference image for controlnet.
          example: ast_01
          type: string
        control_mode:
          description: |
            The priority of the control net: 
            - `0` - The priority between control net and prompt is balanced. 
            - `1` - The prompt priority is higher than the control net. 
            - `2` - The control net priority is higher than the prompt.
          enum:
            - 0
            - 1
            - 2
          example: 0
          type: integer
        name:
          description: >-
            Query the list resources endpoint `GET /pub/v1/controlnets`  to view
            all available controlnets. Make sure your Controlnet has the same
            base model (SD 1.5/SDXL) as your selected style/model.
          example: Normal
          type: string
        resize_mode:
          description: |-
            The relation between the control net image and generated image: 
            - `0` - Resize and Fill. 
            - `1` - Crop and Resize. 
            - `2` - Just Resize.
          enum:
            - 0
            - 1
            - 2
          example: 0
          type: integer
      required:
        - asset_id
        - control_mode
        - name
        - resize_mode
    Facelock:
      type: object
      properties:
        asset_id:
          description: >-
            Upload a reference image of a person using the `POST
            /pub/v1/assets/upload` endpoint. Pass the asset id in the payload to
            create AI characters with the same face as the reference image.
          example: ast_01
          type: string
      required:
        - asset_id
    Lora:
      type: object
      properties:
        name:
          description: The name of the lora
          example: lora_name
          type: string
        weight:
          description: >-
            Specify the strength of the LoRA being applied. Higher values will
            influence the generation more.
          example: 0.5
          maximum: 1
          minimum: 0.1
          type: number
      required:
        - name
        - weight
    Narrator:
      type: object
      properties:
        image_asset_id:
          description: >-
            ID of an image asset for FaceSwap feature. Upload an image asset
            with a face clearly visible, preferably looking forward. You can get
            the details of available image assets using `GET
            /pub/v2/assets?type=image` endpoint or else you can upload one using
            `POST /pub/v2/assets/upload`.
          example: ast_imgxxxxx
          type: string
        video_asset_id:
          description: >-
            ID of a video asset. Uploaded video asset should have only one
            person with a clear view of their face. You can get the details of
            available video assets using `GET /pub/v2/assets?type=video`
            endpoint or else you can upload one using `POST
            /pub/v2/assets/upload?type=video`.
          example: ast_vidxxxxx
          type: string
        audio_asset_id:
          description: >-
            ID of an audio asset. You can get the details of available audio
            assets using `GET /pub/v2/assets?type=audio` endpoint or else you
            can upload one using `POST /pub/v2/assets/upload?type=audio`.
          example: ast_audxxxxx
          type: string
        script:
          description: Describe/share the script you want to hear in the video narration.
          example: Thank you for trying Narrator
          type: string
        voice:
          description: >-
            Query the list resources endpoint `GET /pub/v1/voices` to view all
            available voices, and use any one from it for narrator generation.
          example: Rachel
          type: string
      required:
        - video_asset_id
    Prompt:
      type: object
      properties:
        negative:
          description: The negative prompt
          example: >-
            nsfw, deformed, extra limbs, bad anatomy, deformed pupils, text,
            worst quality, jpeg artifacts, ugly, duplicate, morbid, mutilated
          type: string
        positive:
          description: >-
            The positive prompt. If you are submitting a character for
            generation then make sure to pass the character's name in curly
            braces here. For ex. {Alex} on a trek
          example: a man looking into the camera
          type: string
      required:
        - negative
        - positive
    Segment:
      type: object
      properties:
        asset_id:
          description: >-
            Upload an image using the upload asset endpoint `POST
            /pub/v1/assets/upload`
          example: ast_01
          type: string
        find:
          description: >-
            Describe an element in the image that you want to change. Specify
            only 1 element at a time (eg: black tshirt, red car, hair, etc).
          example: red shirt
          type: string
        replace:
          description: >-
            Describe the element you want to see in the image instead (eg: a
            yellow tshirt, a white car, pink hair, etc).
          example: blue shirt
          type: string
      required:
        - asset_id
        - find
        - replace
    StyleDetail:
      properties:
        name:
          description: The name of the style
          example: Black & White
          type: string
        base_model:
          description: The base model of the style
          type: string
          example: flux
    TrueTouch:
      type: object
      properties:
        asset_id:
          description: >-
            Upload an image using the upload asset endpoint `POST
            /pub/v1/assets/upload`
          example: ast_01
          type: string
        enhance_strength:
          description: >-
            Specify the level of realistic enhancement you want to apply to your
            image.
          example: 0.5
          type: number
        scale_factor:
          description: Specify how much you want to upscale the your image by.
          enum:
            - '1'
            - '1.5'
            - '2'
            - '2.5'
            - '3'
          example: 1.5
          type: number
      required:
        - asset_id
        - enhance_strength
        - scale_factor
    VideoAnyone:
      type: object
      properties:
        media_id:
          description: >-
            This can be either generated image's media_id or an uploaded image
            asset's asset_id that you want to convert to video. (Supported
            Aspect Ratio: `3:5` or `5:3`)
          example: ast_01
          type: string
        prompt:
          description: >-
            A simple prompt to be described that what subject wants to be done
            in the video. (The video prompt is not mandatory input for
            generating video. You can choose to skip it, and we will create a
            video based on the source image)
          example: Camera static, a woman riding a bicycle
          type: string
        duration:
          description: Duration of the output video in seconds
          enum:
            - 5
            - 10
          example: 5
          type: number
          default: 5
      required:
        - media_id
    GenerationResponse:
      properties:
        credits_remaining:
          description: The number of credits remaining
          example: 20
          type: integer
        generation_id:
          description: The id of the generation
          example: gen_01
          type: string
        media:
          items:
            $ref: '#/components/schemas/ImageMetadata'
          type: array
        result:
          description: The result status of the generation
          example: initiated
          type: string
      type: object
    ImageMetadata:
      properties:
        id:
          description: The id of the media
          example: model_01
          type: string
        dim:
          $ref: '#/components/schemas/ImageSize'
        model:
          description: >-
            The model used for the media if model is used in the generation else
            it won't be present
          example: JuggernautXL
          type: string
        status:
          description: The status of the image
          example: initiated
          type: string
        style:
          description: >-
            The style used for the media if style is used in the generation else
            it won't be present
          example: Bokeh
          type: string
        style_detail:
          $ref: '#/components/schemas/StyleDetail'
          description: >-
            The style name along with its base model used for the generation.
            This will only be present in case of a style generation.
        type:
          description: The type of the media generation.
          example: image
          type: string
      type: object
    ImageSize:
      type: object
      properties:
        height:
          description: The height of the image
          example: 512
          type: integer
        width:
          description: The width of the image
          example: 512
          type: integer
      required:
        - height
        - width

````