Generate Stunning Images with Atenealabs' Cognitive Actions

22 Apr 2025
Generate Stunning Images with Atenealabs' Cognitive Actions

In today's digital landscape, the ability to create high-quality images programmatically can significantly enhance applications across various domains, from gaming to marketing. The Atenealabs' Cognitive Actions serve as a powerful solution for developers looking to integrate image generation capabilities into their applications. This guide will walk you through the "Generate Image with Custom Parameters" action in the atenealabsbackup/tok-my-flux-lora spec, illustrating how you can harness its features to create unique images tailored to your specifications.

Prerequisites

Before diving into the Cognitive Actions, ensure you have:

  • An API key for the Cognitive Actions platform.
  • Basic knowledge of making HTTP requests and handling JSON data.

Authentication typically involves passing your API key in the request headers to access the functionality securely.

Cognitive Actions Overview

Generate Image with Custom Parameters

The Generate Image with Custom Parameters action allows you to produce high-quality images using a variety of customizable parameters. This includes settings for size, aspect ratio, and image quality, with options for inpainting mode and different models for fast and detailed predictions.

Input

The input for this action is structured as follows:

{
  "prompt": "a portrait of TOK, libertarian, intelectual, leader",
  "model": "dev",
  "goFast": false,
  "imageFormat": "png",
  "outputCount": 1,
  "imageQuality": 80,
  "loraIntensity": 1,
  "inferenceSteps": 28,
  "imageMegapixels": "1",
  "promptIntensity": 0.8,
  "imageAspectRatio": "16:9",
  "guidanceIntensity": 3,
  "additionalLoraIntensity": 1
}
  • Required Fields:
    • prompt: A string describing the image to be generated.
  • Optional Fields:
    • mask: URI for an image mask (for inpainting).
    • seed: An integer for reproducibility.
    • image: URI for an input image (for image-to-image generation).
    • model: Select from "dev" or "schnell".
    • width and height: Dimensions of the generated image if aspect ratio is custom.
    • goFast: A boolean to enable faster predictions.
    • Additional parameters for fine-tuning the generation process.

Output

The action returns a URL pointing to the generated image. An example output is as follows:

[
  "https://assets.cognitiveactions.com/invocations/647cc29a-fb18-4595-b028-0baeda0972dd/9f883939-472c-43f5-971a-51792392abc7.png"
]

This URL can be used to view or download the generated image directly.

Conceptual Usage Example (Python)

Below is a conceptual example of how to call the Generate Image with Custom Parameters 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 = "a0cd7b57-e404-4b20-aaea-da9697b4aead" # Action ID for Generate Image with Custom Parameters

# Construct the input payload based on the action's requirements
payload = {
    "prompt": "a portrait of TOK, libertarian, intelectual, leader",
    "model": "dev",
    "goFast": False,
    "imageFormat": "png",
    "outputCount": 1,
    "imageQuality": 80,
    "loraIntensity": 1,
    "inferenceSteps": 28,
    "imageMegapixels": "1",
    "promptIntensity": 0.8,
    "imageAspectRatio": "16:9",
    "guidanceIntensity": 3,
    "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, replace "YOUR_COGNITIVE_ACTIONS_API_KEY" with your actual API key. The payload variable is structured according to the action's requirements, showcasing how to set the prompt and other parameters effectively.

Conclusion

The Generate Image with Custom Parameters action from Atenealabs' Cognitive Actions opens up exciting possibilities for developers looking to enhance their applications with dynamic image generation. With customizable parameters, you can create stunning visuals tailored to your specific needs. Explore the capabilities of this action and consider how it might fit into your next project! Happy coding!