Create Stunning Videos with HunyuanVideo LoRA Cognitive Actions

24 Apr 2025
Create Stunning Videos with HunyuanVideo LoRA Cognitive Actions

In today's digital landscape, the demand for customized video content is skyrocketing. The HunyuanVideo LoRA Cognitive Actions allow developers to generate tailored videos from text descriptions seamlessly. By harnessing the power of HunyuanVideo with support for Low-Rank Adaptation (LoRA) files, these actions enable style customization and the ability to train your own models, enhancing the aesthetic of videos without altering the main model. This article will guide you through integrating this powerful API into your applications.

Prerequisites

Before diving into the integration, ensure you have the following:

  • API Key: You will need an API key for the Cognitive Actions platform to authenticate your requests.
  • Basic understanding of JSON: Familiarity with JSON format will help you structure your input payload correctly.

Conceptually, authentication is done by passing your API key in the headers of your requests.

Cognitive Actions Overview

Create Video with HunyuanVideo LoRA

The Create Video with HunyuanVideo LoRA action generates customized videos based on text prompts. This action offers various parameters to control video characteristics, such as dimensions, frame rate, and quality. It is categorized under video-generation.

Input

The input for this action consists of multiple fields. Below is a breakdown of the required and optional parameters based on the schema:

  • seed (integer, optional): Sets a seed for consistent video generation. Defaults to random if not specified.
  • steps (integer, optional): The number of diffusion steps to be performed. Default is 50 steps, but it can range from 1 to 150.
  • width (integer, optional): Specifies the width in pixels for the generated video. Default is 640, with a minimum of 64 and a maximum of 1536.
  • height (integer, optional): Specifies the height in pixels for the generated video. Default is 360, with a minimum of 64 and a maximum of 1024.
  • prompt (string, required): The text prompt describing your video scene.
  • flowShift (integer, optional): Determines the continuity factor of the video flow. Default value is 9, within a range of 0 to 20.
  • frameRate (integer, optional): Sets the video frame rate in frames per second. The default is 16 fps, ranging from 1 to 60.
  • scheduler (string, optional): Selects the scheduling algorithm used to generate video frames. Default is DPMSolverMultistepScheduler.
  • enhanceEnd (number, optional): Specifies the point in the video to end enhancement.
  • frameCount (integer, optional): Defines the total number of frames in the generated video. Defaults to 33 frames, ranging from 1 to 1440.
  • qualityRate (integer, optional): Sets the CRF (Constant Rate Factor) quality for H264 encoding. Lower values result in higher quality. Range is 0 to 51, default is 19.
  • enhanceStart (number, optional): Indicates the point in the video to start enhancement.
  • forceOffload (boolean, optional): Determines whether model layers are offloaded to the CPU. Default is true.
  • loraStrength (number, optional): Sets the scale or strength for your LoRA. Default is 1, ranging from -10 to 10.
  • enhanceDouble (boolean, optional): Applies enhancement to pairs of frames.
  • enhanceSingle (boolean, optional): Applies enhancement to each individual frame.
  • enhanceWeight (number, optional): Determines the strength of the video enhancement effect. Default is 0.3, ranging from 0 to 2.
  • guidanceScale (number, optional): Balances the influence of the text prompt against the model's innate capabilities. Default is 6, from a range of 0 to 30.
  • denoiseStrength (number, optional): Controls the strength of noise added at each step. Default is 1, with a minimum of 0 and a maximum of 2.
  • modelResourceUrl (string, optional): URL pointing to a LoRA .safetensors file or a Hugging Face repository.
  • resourceWeightsFile (string, optional): A .tar file containing LoRA weights.

Example Input:

{
  "steps": 30,
  "width": 512,
  "height": 512,
  "prompt": "In the style of RSNG. A woman with blonde hair stands on a balcony at night, framed against a backdrop of city lights. She wears a white crop top and a dark jacket, exuding a confident presence as she gazes directly at the camera.",
  "flowShift": 9,
  "frameRate": 15,
  "scheduler": "DPMSolverMultistepScheduler",
  "enhanceEnd": 1,
  "frameCount": 33,
  "qualityRate": 19,
  "enhanceStart": 0,
  "forceOffload": true,
  "loraStrength": 1,
  "enhanceDouble": true,
  "enhanceSingle": true,
  "enhanceWeight": 0.3,
  "guidanceScale": 6,
  "denoiseStrength": 1,
  "modelResourceUrl": "lucataco/hunyuan-musubi-rose-6"
}

Output

The action typically returns a URL for the generated video. For example:

https://assets.cognitiveactions.com/invocations/23aca17a-40d1-443d-bcaa-5cf9e51244ea/35ff4282-ac5e-42d3-a4b0-e04d5598b5e1.mp4

Conceptual Usage Example (Python)

Here’s how you might call the Create Video with HunyuanVideo LoRA action using Python:

import requests
import json

# Replace with your Cognitive Actions API key and endpoint
COGNITIVE_ACTIONS_API_KEY = "YOUR_COGNITIVE_ACTIONS_API_KEY"
COGNITIVE_ACTIONS_EXECUTE_URL = "https://api.cognitiveactions.com/actions/execute" # Hypothetical endpoint

action_id = "d3e4d0f8-7325-4c1d-8555-286dae8ab452" # Action ID for Create Video with HunyuanVideo LoRA

# Construct the input payload based on the action's requirements
payload = {
    "steps": 30,
    "width": 512,
    "height": 512,
    "prompt": "In the style of RSNG. A woman with blonde hair stands on a balcony at night, framed against a backdrop of city lights...",
    "flowShift": 9,
    "frameRate": 15,
    "scheduler": "DPMSolverMultistepScheduler",
    "enhanceEnd": 1,
    "frameCount": 33,
    "qualityRate": 19,
    "enhanceStart": 0,
    "forceOffload": True,
    "loraStrength": 1,
    "enhanceDouble": True,
    "enhanceSingle": True,
    "enhanceWeight": 0.3,
    "guidanceScale": 6,
    "denoiseStrength": 1,
    "modelResourceUrl": "lucataco/hunyuan-musubi-rose-6"
}

headers = {
    "Authorization": f"Bearer {COGNITIVE_ACTIONS_API_KEY}",
    "Content-Type": "application/json"
}

try:
    response = requests.post(
        COGNITIVE_ACTIONS_EXECUTE_URL,
        headers=headers,
        json={"action_id": action_id, "inputs": payload} # Hypothetical structure
    )
    response.raise_for_status() # Raise an exception for bad status codes (4xx or 5xx)

    result = response.json()
    print("Action executed successfully:")
    print(json.dumps(result, indent=2))

except requests.exceptions.RequestException as e:
    print(f"Error executing action {action_id}: {e}")
    if e.response is not None:
        print(f"Response status: {e.response.status_code}")
        try:
            print(f"Response body: {e.response.json()}")
        except json.JSONDecodeError:
            print(f"Response body: {e.response.text}")

In this code snippet, replace the COGNITIVE_ACTIONS_API_KEY with your valid API key and adjust the endpoint URL if necessary. The action_id is for the specific action you're calling. The input payload is structured based on the action's requirements.

Conclusion

Integrating the HunyuanVideo LoRA Cognitive Actions into your applications opens up vast possibilities for video creation. By leveraging these actions, you can generate high-quality, customized videos that meet your specific needs. Whether you're creating content for marketing, storytelling, or educational purposes, the flexibility and power of these Cognitive Actions will enhance your workflow significantly. Start experimenting today and unlock your creative potential!