Create Stunning Images with the leonardoa2/draganhooltutto Cognitive Actions

21 Apr 2025
Create Stunning Images with the leonardoa2/draganhooltutto Cognitive Actions

In the world of AI and image generation, the leonardoa2/draganhooltutto Cognitive Actions offer powerful tools to create visually striking images from textual prompts. By leveraging these pre-built actions, developers can easily integrate sophisticated image generation capabilities into their applications. This article will guide you through the available action, detailing its features and how to utilize it effectively.

Prerequisites

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

  • An API key for the Cognitive Actions platform.
  • Basic knowledge of making HTTP requests.
  • A programming environment set up for making API calls.

Authentication typically involves passing your API key in the request headers, allowing you to securely interact with the Cognitive Actions endpoint.

Cognitive Actions Overview

Generate Stylized Image

The Generate Stylized Image action allows you to create images based on a descriptive text prompt. With various options for inpainting, custom image sizes, and styles, this action supports both quick and detailed generation modes.

Input

The input for this action is structured as follows:

  • Required Field:
    • prompt (string): The text prompt that describes the desired image.
  • Optional Fields:
    • mask (string): URI of an image mask for inpainting.
    • seed (integer): Integer seed for reproducible results.
    • image (string): Input image for transformations.
    • model (string): Choose between 'dev' or 'schnell' (default is 'dev').
    • width (integer): Width of the image (256 to 1440).
    • height (integer): Height of the image (256 to 1440).
    • megapixels (string): Approximate megapixels (1 or 0.25).
    • outputCount (integer): Number of images to generate (1 to 4).
    • useFastMode (boolean): Enable faster generation mode.
    • outputFormat (string): Format of the output image (webp, jpg, png).
    • guidanceScale (number): Scale for guiding the image generation (0 to 10).
    • outputQuality (integer): Quality of output images (0 to 100).
    • additionalLora (string): Load additional LoRA weights.
    • promptStrength (number): Strength of the prompt (0 to 1).
    • imageAspectRatio (string): Aspect ratio of the image.
    • inferenceStepCount (integer): Number of steps in the generation process (1 to 50).

Example Input:

{
  "model": "dev",
  "prompt": "A pack of young hooligans elegantly dressed in formal attire—striding confidently through the streets of Manchester.",
  "outputCount": 4,
  "outputFormat": "jpg",
  "guidanceScale": 3.5,
  "outputQuality": 90,
  "promptStrength": 0.8,
  "imageAspectRatio": "16:9",
  "inferenceStepCount": 28,
  "primaryLoraStrength": 1
}

Output

When the action is executed successfully, it typically returns an array of URLs pointing to the generated images. For instance:

Example Output:

[
  "https://assets.cognitiveactions.com/invocations/61494687-f4ad-4119-b8b4-7f607ac24078/33b2f4fa-c6a4-44a1-b0df-067e30351929.jpg",
  "https://assets.cognitiveactions.com/invocations/61494687-f4ad-4119-b8b4-7f607ac24078/7468cc46-75da-4d60-93f6-8ab0fce72916.jpg",
  "https://assets.cognitiveactions.com/invocations/61494687-f4ad-4119-b8b4-7f607ac24078/1d1ce340-233f-44e5-a41c-0e9f7cfc2349.jpg",
  "https://assets.cognitiveactions.com/invocations/61494687-f4ad-4119-b8b4-7f607ac24078/13184b5b-6c93-445b-bb66-4a8c857ec5ad.jpg"
]

Conceptual Usage Example (Python)

Here’s how you might call the Generate Stylized Image action using a conceptual Python snippet:

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 = "d8c67a56-789e-46f3-9b44-e68ee30d26e8" # Action ID for Generate Stylized Image

# Construct the input payload based on the action's requirements
payload = {
    "model": "dev",
    "prompt": "A pack of young hooligans elegantly dressed in formal attire—striding confidently through the streets of Manchester.",
    "outputCount": 4,
    "outputFormat": "jpg",
    "guidanceScale": 3.5,
    "outputQuality": 90,
    "promptStrength": 0.8,
    "imageAspectRatio": "16:9",
    "inferenceStepCount": 28,
    "primaryLoraStrength": 1
}

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, you'll see how to replace the action ID and input payload appropriately to execute the action. The endpoint URL and exact request structure are illustrative and may differ based on actual implementation.

Conclusion

The leonardoa2/draganhooltutto Cognitive Actions provide a straightforward way for developers to create stunning images from text prompts. With a variety of configuration options, you can tailor the output to fit your project's needs. Whether you’re looking to enhance your application with unique visuals or experiment with AI-driven creativity, these actions can serve as a powerful resource.

Explore the possibilities of image generation and integrate these actions into your applications today!