Create Stunning Videos with LaVie Cognitive Actions

24 Apr 2025
Create Stunning Videos with LaVie Cognitive Actions

In the world of video content creation, having the right tools can significantly enhance your productivity and creativity. The LaVie Cognitive Actions offer developers a powerful API for generating high-quality videos using advanced models, enabling you to transform text prompts into visually captivating video sequences. These pre-built actions streamline the video generation process, allowing you to focus on crafting engaging narratives and visuals without delving deep into complex algorithms.

Prerequisites

Before you begin integrating the LaVie Cognitive Actions into your applications, ensure you have the following:

  • An API key for accessing the Cognitive Actions platform.
  • Basic knowledge of making HTTP requests using your preferred programming language.
  • Familiarity with JSON structure, as you'll be working with JSON payloads for input and output.

For authentication, you will typically need to include your API key in the request headers. Here’s how you might structure the authorization in your requests:

Authorization: Bearer YOUR_COGNITIVE_ACTIONS_API_KEY

Cognitive Actions Overview

Generate High-Quality Video with LaVie

The Generate High-Quality Video with LaVie action allows you to create stunning videos from textual descriptions using the LaVie framework, which utilizes cascaded latent diffusion models. You can customize various settings such as video resolution, quality, and sampling methods to suit your needs.

  • Category: Video Generation

Input

The action requires a JSON object with the following fields:

FieldTypeDescriptionDefault Value
seedIntegerRandom seed for video generation. Leave blank or set to null for randomization.(optional)
widthIntegerWidth of the output video in pixels.512
heightIntegerHeight of the output video in pixels.320
promptStringText prompt directing the generation of the video content."a Corgi walking in the park at sunrise, oil painting style"
qualityIntegerQuality of the output video (0-10 scale).9
guidanceScaleNumberGuidance scale factor for classifier-free guidance.7
interpolationBooleanIf true, the output contains 61 frames instead of the default 16.false
samplingMethodStringScheduler for sampling in base video output. Options: 'ddim', 'eulerdiscrete', 'ddpm'.'ddpm'
superResolutionBooleanIf true, enhances the video resolution by a factor of 4.false
videoFramesPerSecondIntegerDefines the number of frames per second in the output video.8
numberOfInferenceStepsIntegerTotal number of denoising inference steps to be used.250

Example Input

Here’s a practical example of the JSON payload you would use to invoke this action:

{
  "width": 512,
  "height": 320,
  "prompt": "a Corgi walking in the park at sunrise, oil painting style",
  "quality": 9,
  "guidanceScale": 7,
  "interpolation": false,
  "samplingMethod": "ddpm",
  "superResolution": false,
  "videoFramesPerSecond": 8,
  "numberOfInferenceSteps": 50
}

Output

Upon a successful request, the action typically returns a URL to the generated video:

https://assets.cognitiveactions.com/invocations/25367538-9310-451e-93d0-fd4125863798/0315ad1d-8158-477b-99e6-668ac31366e4.mp4

Conceptual Usage Example (Python)

Here’s a conceptual Python snippet demonstrating how to call the Generate High-Quality Video action:

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 = "4df351b3-bfa0-4f3b-9ba1-b5ef0578940e" # Action ID for Generate High-Quality Video

# Construct the input payload based on the action's requirements
payload = {
    "width": 512,
    "height": 320,
    "prompt": "a Corgi walking in the park at sunrise, oil painting style",
    "quality": 9,
    "guidanceScale": 7,
    "interpolation": False,
    "samplingMethod": "ddpm",
    "superResolution": False,
    "videoFramesPerSecond": 8,
    "numberOfInferenceSteps": 50
}

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 the above code, replace YOUR_COGNITIVE_ACTIONS_API_KEY with your actual API key. The snippet constructs the input JSON payload and posts it to the hypothetical Cognitive Actions endpoint, handling any errors that may occur during the request.

Conclusion

The LaVie Cognitive Actions provide a robust solution for developers looking to generate high-quality videos from text descriptions. By leveraging the capabilities of this API, you can create visually engaging content quickly and efficiently. Consider exploring more use cases, such as integrating video generation into applications for marketing, storytelling, or educational purposes. The possibilities are endless with the power of LaVie at your fingertips!