Elevate Your Image Generation with faezmurshidi/lat Cognitive Actions

23 Apr 2025
Elevate Your Image Generation with faezmurshidi/lat Cognitive Actions

In the world of AI-driven creativity, the faezmurshidi/lat Cognitive Actions shine as a powerful tool for developers looking to enhance their applications with advanced image generation capabilities. These pre-built actions allow for customized and detailed image creation, utilizing advanced models to bring your ideas to life. With features such as image inpainting, aspect ratio adjustments, and fast prediction modes, integrating these actions into your application can significantly boost its functionality and user experience.

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 how to make HTTP requests and handle JSON data.
  • Familiarity with Python or your preferred programming language for executing API calls.

Authentication typically involves including your API key in the request headers, ensuring secure access to the Cognitive Actions functionalities.

Cognitive Actions Overview

Generate Enhanced Images

The Generate Enhanced Images action is the core functionality of the faezmurshidi/lat spec. It enables the creation of high-quality images based on user-defined prompts, leveraging two advanced models—dev and schnell—for various generation needs.

Purpose: Generate customized and detailed images with options for inpainting, aspect ratio settings, and fast prediction modes.

Category: image-generation

Input

The input schema for this action is defined as follows:

  • Required:
    • prompt: A string describing what you want the generated image to depict.
  • Optional:
    • mask: A URI string for image inpainting mode.
    • seed: An integer for reproducible image generation.
    • image: A URI string for input images in image-to-image or inpainting modes.
    • model: Choose between "dev" (default) or "schnell".
    • width: Integer specifying the image width (if aspect ratio is custom).
    • height: Integer specifying the image height (if aspect ratio is custom).
    • imageFormat: Select output format ("webp", "jpg", or "png").
    • outputCount: Number of images to generate (1 to 4).
    • ratioAspect: Aspect ratio of the image.
    • imageQuality: Quality level from 0 to 100.
    • loraIntensity: Intensity of the main LoRA application.
    • denoisingSteps: Number of steps for finer details (1 to 50).
    • guidanceIntensity: Scale of guidance for the generation process.
    • enableAcceleration: Boolean to enable faster predictions.
    • resolutionInMegapixels: Approximate resolution for the image.
    • Other parameters related to LoRA weights and intensities.

Example Input:

{
  "model": "dev",
  "prompt": "A LAT cartoon drawing, in black and white, of a group of people standing outside of a house playing cricket. The drawing is in a comic book style, with a sense of nostalgia and a touch of humor.",
  "imageFormat": "webp",
  "outputCount": 1,
  "ratioAspect": "1:1",
  "imageQuality": 80,
  "loraIntensity": 1,
  "denoisingSteps": 28,
  "guidanceIntensity": 3,
  "enableAcceleration": false,
  "suggestionIntensity": 0.8,
  "resolutionInMegapixels": "1",
  "additionalLoraIntensity": 1
}

Output

The action typically returns an array of URLs pointing to the generated images. Each URL leads to an image in the specified format.

Example Output:

[
  "https://assets.cognitiveactions.com/invocations/911c22be-ecbe-4974-9ab3-63c4106c10de/e239c74a-ee44-4294-881c-f5eae20ca767.webp"
]

Conceptual Usage Example (Python)

Here’s a conceptual Python code snippet demonstrating how to call the Generate Enhanced Images 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 = "5e9ed8bd-cda8-4156-b2f8-fc273a568280"  # Action ID for Generate Enhanced Images

# Construct the input payload based on the action's requirements
payload = {
    "model": "dev",
    "prompt": "A LAT cartoon drawing, in black and white, of a group of people standing outside of a house playing cricket. The drawing is in a comic book style, with a sense of nostalgia and a touch of humor.",
    "imageFormat": "webp",
    "outputCount": 1,
    "ratioAspect": "1:1",
    "imageQuality": 80,
    "loraIntensity": 1,
    "denoisingSteps": 28,
    "guidanceIntensity": 3,
    "enableAcceleration": False,
    "suggestionIntensity": 0.8,
    "resolutionInMegapixels": "1",
    "additionalLoraIntensity": 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 example, the action_id is set for the Generate Enhanced Images action, and the payload is structured to meet the action's input requirements. Replace the hypothetical endpoint and API key with your actual credentials.

Conclusion

The faezmurshidi/lat Cognitive Actions offer robust capabilities for image generation, allowing developers to create stunning visuals with ease. By leveraging these pre-built actions, you can enhance your applications' creativity and user engagement. Explore various use cases, from artistic creations to practical image editing and beyond, to fully utilize the potential of this powerful toolset. Start integrating today and bring your ideas to life!