Create Custom Videos from Text with Hunyuan Video LoRA Actions

24 Apr 2025
Create Custom Videos from Text with Hunyuan Video LoRA Actions

In today's digital landscape, the ability to generate video content from simple text descriptions opens up exciting possibilities for developers. The Hunyuan Video LoRA Actions provide a powerful API for creating customizable videos using text inputs, enhanced with Low-Rank Adaptation (LoRA) support. This functionality allows developers to infuse unique styles and characters into the generated videos, making it easier than ever to create tailored visual content for various applications.

Prerequisites

To effectively utilize the Hunyuan Video LoRA Actions, you will need:

  • An API key for accessing the Cognitive Actions platform.
  • Basic familiarity with JSON and API interactions.

Authentication typically involves passing your API key in the request headers to ensure secure access to the service.

Cognitive Actions Overview

Generate Video from Text with HunyuanVideo

The Generate Video from Text with HunyuanVideo action allows you to create videos from descriptive text prompts. This action is particularly useful for developers looking to produce engaging video content programmatically. You can customize various parameters, including video size, frame rate, and even the influence of LoRA files for unique stylization.

Input

The input for this action follows a structured schema. Here’s a breakdown of the required and optional fields:

  • seed (integer, optional): Seed value for reproducibility. If omitted, a random seed is used.
  • steps (integer, optional): Number of diffusion steps (default is 50, range: 1-150).
  • width (integer, optional): Width of the video in pixels (default is 640, range: 64-1536).
  • height (integer, optional): Height of the video in pixels (default is 360, range: 64-1024).
  • prompt (string, required): Descriptive text for the video scene.
  • loraFileUrl (string, optional): URL for the LoRA .safetensors file.
  • totalFrames (integer, optional): Number of frames in the video (default is 85, range: 1-300).
  • loraIntensity (number, optional): Strength of the LoRA configuration.
  • qualityFactor (integer, optional): CRF for video encoding (default is 19, range: 0-51).
  • noiseIntensity (number, optional): Intensity of noise applied at each step (default is 1).
  • videoFrameRate (integer, optional): Frames per second for the video (default is 24, range: 1-60).
  • forceCpuOffload (boolean, optional): Option to offload model layers to CPU (default is true).
  • loraWeightsFile (string, optional): URI for LoRA weights (optional).
  • textInfluenceScale (number, optional): Influence of text prompts versus model behavior (default is 6).
  • videoFlowContinuity (integer, optional): Continuity factor for video flow (default is 9, range: 0-20).

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.",
  "loraFileUrl": "lucataco/hunyuan-musubi-rose-6",
  "totalFrames": 33,
  "loraIntensity": 1,
  "qualityFactor": 19,
  "noiseIntensity": 1,
  "videoFrameRate": 15,
  "forceCpuOffload": true,
  "textInfluenceScale": 6,
  "videoFlowContinuity": 9
}

Output

Upon successful execution, this action returns a URL pointing to the generated video file.

Example Output:

https://assets.cognitiveactions.com/invocations/9a6e4810-8544-4fe9-8cc7-c3a5a38d9969/026529c0-19d4-41d9-863c-b3650a8d1bfe.mp4

Conceptual Usage Example (Python)

Below is a conceptual Python snippet demonstrating how to call the Hunyuan Video LoRA action using a hypothetical endpoint:

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 = "1bcac24d-2dac-43e7-b1fd-7a0c4fedbe05"  # Action ID for Generate Video from Text

# 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. She wears a white crop top and a dark jacket, exuding a confident presence as she gazes directly at the camera.",
    "loraFileUrl": "lucataco/hunyuan-musubi-rose-6",
    "totalFrames": 33,
    "loraIntensity": 1,
    "qualityFactor": 19,
    "noiseIntensity": 1,
    "videoFrameRate": 15,
    "forceCpuOffload": True,
    "textInfluenceScale": 6,
    "videoFlowContinuity": 9
}

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 example, replace the placeholder API key and endpoint with your actual credentials. The action ID corresponds to the video generation action, and the payload is structured according to the requirements of the action.

Conclusion

The Hunyuan Video LoRA Actions offer an innovative way for developers to generate customized video content from text descriptions. By leveraging the flexibility of LoRA files and various adjustable parameters, you can create engaging and unique videos tailored to your specific needs. Start exploring the endless possibilities today and enhance your applications with dynamic video content!