Create Stunning Animated Videos with lucataco/animate-diff-sdxl-lcm Cognitive Actions

24 Apr 2025
Create Stunning Animated Videos with lucataco/animate-diff-sdxl-lcm Cognitive Actions

In today's digital landscape, creating engaging multimedia content is crucial for capturing audience attention. The lucataco/animate-diff-sdxl-lcm API offers a powerful Cognitive Action that allows developers to generate high-resolution animated videos using personalized text-to-image diffusion models. With customizable parameters such as video duration, aspect ratio, and more, you can easily create unique animations that resonate with your audience.

Prerequisites

Before you dive into using the Cognitive Actions, ensure you have the following:

  • An API key for the Cognitive Actions platform to authenticate your requests.
  • Familiarity with JSON structure, as you'll be sending and receiving data in this format.

Authentication typically involves passing your API key in the request headers, ensuring that only authorized users can access the service.

Cognitive Actions Overview

Animate Text-to-Image Diffusion

Description: This action generates high-resolution animated videos based on textual prompts using diffusion models like SDXL and LCM. It allows for extensive customization, enabling developers to create animations that match specific requirements.

Category: Video Generation

Input

The input schema for this action consists of several fields allowing for detailed customization:

  • seed (integer, optional): A random seed for reproducible outputs (0 for random behavior). Valid range: 0 to 2147483647.
  • steps (integer, optional): Number of inference steps used in processing (1 to 100). Default is 6.
  • aspect (string, optional): Desired aspect ratio for the output image. Options include "9:16", "2:3", "1:1", "3:2", "16:9". Default is "1:1".
  • prompt (string, required): Descriptive prompt guiding the output generation.
  • checkpoint (string, optional): Chooses a specific model checkpoint for processing. Options are "dynavision", "dreamshaper", "deepblue". Default is "dynavision".
  • videoLength (integer, optional): Specifies the duration of the video output (must be 16 or more frames). Default is 16.
  • motionModule (string, optional): Selects the motion model to be used. Currently, only "mm_sdxl_v10_beta" is available.
  • guidanceScale (number, optional): Influences adherence to the input prompt (1 to 10). Default is 1.
  • returnTypeMp4 (boolean, optional): Determines the format of the output (MP4 or GIF). Default is true.
  • useCheckpoint (boolean, optional): Decides whether to use a pre-trained model checkpoint for generation. Defaults to false.
  • negativePrompt (string, optional): Specifies elements to avoid in the generation.

Example Input:

{
  "seed": 0,
  "steps": 6,
  "aspect": "1:1",
  "prompt": "A panda standing on a surfboard in the ocean in sunset, 4k, high resolution. Realistic, Cinematic, high resolution",
  "checkpoint": "dynavision",
  "videoLength": 16,
  "motionModule": "mm_sdxl_v10_beta",
  "guidanceScale": 1,
  "returnTypeMp4": true,
  "useCheckpoint": false,
  "negativePrompt": ""
}

Output

The output typically returns a URL to the generated video file. For example:

https://assets.cognitiveactions.com/invocations/b5cf882b-7691-4b3b-95a2-5fe6a15e445a/388ad157-3da4-4ed0-ab09-6980d59fbd57.mp4

This URL leads to the high-resolution animated video created based on your input parameters.

Conceptual Usage Example (Python)

Here's how you might call this Cognitive 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 = "666a748e-bd4f-474d-bc88-60d7416804bc" # Action ID for Animate Text-to-Image Diffusion

# Construct the input payload based on the action's requirements
payload = {
    "seed": 0,
    "steps": 6,
    "aspect": "1:1",
    "prompt": "A panda standing on a surfboard in the ocean in sunset, 4k, high resolution. Realistic, Cinematic, high resolution",
    "checkpoint": "dynavision",
    "videoLength": 16,
    "motionModule": "mm_sdxl_v10_beta",
    "guidanceScale": 1,
    "returnTypeMp4": true,
    "useCheckpoint": false,
    "negativePrompt": ""
}

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 YOUR_COGNITIVE_ACTIONS_API_KEY with your actual API key. The payload variable is constructed according to the action's requirements, and the response will provide the URL to your generated video.

Conclusion

The lucataco/animate-diff-sdxl-lcm Cognitive Action opens the door to creating captivating animated videos from textual prompts. With its customizable options, developers can harness this powerful tool to enhance content, engage users, and streamline multimedia production. Explore this action today and take your applications to the next level!