Transform Text into Stunning Videos with zsxkib/hunyuan-video2video Cognitive Actions

21 Apr 2025
Transform Text into Stunning Videos with zsxkib/hunyuan-video2video Cognitive Actions

In the realm of video generation, the zsxkib/hunyuan-video2video API provides a remarkable capability to create high-quality videos from textual descriptions. Using Tencent’s HunyuanVideo framework, developers can leverage these Cognitive Actions to generate impressive video content efficiently. By integrating these pre-built actions into your applications, you can automate the process of video creation, enhancing your projects with minimal effort.

Prerequisites

Before diving into the integration of Cognitive Actions, ensure you have the following:

  • An API key for accessing the Cognitive Actions platform.
  • A basic understanding of making HTTP requests and handling JSON data.

Authentication is typically handled by passing the API key in the request headers, allowing secure access to the actions.

Cognitive Actions Overview

Generate Video From Text

The Generate Video From Text action allows you to transform textual descriptions into captivating videos. This action is particularly powerful for creating videos that require realistic motion and high quality based on the provided prompt.

Input

The input for this action requires a JSON payload structured according to the following schema:

{
  "video": "https://example.com/input-video.mp4",
  "prompt": "high quality nature video of a excited Bengal Tiger walking through the grass, masterpiece, best quality",
  "steps": 30,
  "width": 768,
  "height": 768,
  "flowShift": 9,
  "forceRate": 0,
  "forceSize": "Disabled",
  "frameRate": 24,
  "customWidth": 512,
  "customHeight": 512,
  "frameLoadCap": 101,
  "guidanceScale": 6,
  "keepProportion": true,
  "selectEveryNth": 1,
  "denoiseStrength": 0.85,
  "skipFirstFrames": 0,
  "constantRateFactor": 19
}
  • Required Fields:
    • video: URI of the input video file to be processed.
  • Optional Fields:
    • seed: For reproducibility (integer).
    • steps: Number of sampling steps (default 30, max 150).
    • prompt: Detailed text prompt for video content.
    • width: Output video width (default 768).
    • height: Output video height (default 768).
    • flowShift: Controls temporal consistency (default 9).
    • frameRate: Output video frame rate (default 24).
    • Additional fields for fine-tuning, such as guidanceScale, denoiseStrength, etc.

Example Input

Here is an example of a JSON payload that could be sent to this action:

{
  "steps": 30,
  "video": "https://replicate.delivery/pbxt/M5n5MuDgBxhSERj6PvHgz4BJcOUdHc9o1ZBXz454GoGP5DrR/2024-12-03-18%3A25%3A47_seed47039_A%20cat%20walks%20on%20the%20grass%2C%20realistic%20style..mp4",
  "width": 768,
  "height": 768,
  "prompt": "high quality nature video of a excited Bengal Tiger walking through the grass, masterpiece, best quality",
  "flowShift": 9,
  "forceRate": 0,
  "forceSize": "Disabled",
  "frameRate": 24,
  "customWidth": 512,
  "customHeight": 512,
  "frameLoadCap": 101,
  "guidanceScale": 6,
  "keepProportion": true,
  "selectEveryNth": 1,
  "denoiseStrength": 0.85,
  "skipFirstFrames": 0,
  "constantRateFactor": 19
}

Output

Upon successful execution, this action typically returns a URL to the generated video. An example of a successful output URL is:

https://assets.cognitiveactions.com/invocations/910d63a7-af55-44c2-8857-f9ecdde62a3e/ac67f3f5-9bb7-4c8c-9496-a4cdb8a955cd.mp4

Conceptual Usage Example (Python)

Here’s a conceptual example of how you might call this 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 = "8e1029c1-3aa9-4157-924d-97437ce3eca8" # Action ID for Generate Video From Text

# Construct the input payload based on the action's requirements
payload = {
    "steps": 30,
    "video": "https://replicate.delivery/pbxt/M5n5MuDgBxhSERj6PvHgz4BJcOUdHc9o1ZBXz454GoGP5DrR/2024-12-03-18%3A25%3A47_seed47039_A%20cat%20walks%20on%20the%20grass%2C%20realistic%20style..mp4",
    "width": 768,
    "height": 768,
    "prompt": "high quality nature video of a excited Bengal Tiger walking through the grass, masterpiece, best quality",
    "flowShift": 9,
    "forceRate": 0,
    "forceSize": "Disabled",
    "frameRate": 24,
    "customWidth": 512,
    "customHeight": 512,
    "frameLoadCap": 101,
    "guidanceScale": 6,
    "keepProportion": True,
    "selectEveryNth": 1,
    "denoiseStrength": 0.85,
    "skipFirstFrames": 0,
    "constantRateFactor": 19
}

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 YOUR_COGNITIVE_ACTIONS_API_KEY with your actual API key. The action_id is specified to identify the action being called, and the input payload is structured according to the action's requirements.

Conclusion

The zsxkib/hunyuan-video2video Cognitive Actions offer an innovative way to create videos from text prompts, empowering developers to generate rich multimedia content easily. By utilizing the Generate Video From Text action, you can bring your creative ideas to life while saving time and effort in the production process. Explore integrating these actions into your applications to enhance user engagement and storytelling capabilities!