Enhance Your Image Generation with the hadasadler/amitko Cognitive Actions

22 Apr 2025
Enhance Your Image Generation with the hadasadler/amitko Cognitive Actions

In the ever-evolving field of image generation, the hadasadler/amitko API offers powerful Cognitive Actions that leverage advanced techniques to create stunning visual content. Among its offerings is the ability to generate enhanced images through sophisticated inpainting methods. These pre-built actions allow developers to seamlessly integrate image generation capabilities into their applications, saving time and effort while enhancing functionality.

Prerequisites

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

  • An API key for the Cognitive Actions platform, which you will pass as an authorization header in your requests.
  • Basic familiarity with JSON payloads and HTTP requests.

Authentication typically involves including your API key in the request headers as shown in the examples below.

Cognitive Actions Overview

Generate Enhanced Images

The Generate Enhanced Images action is designed to create images using advanced inpainting techniques. It supports customizable dimensions, output quality, and various image styles through different model configurations. This action is categorized under image-generation.

Input

The input schema for this action requires a prompt and supports several optional parameters as outlined below:

  • prompt (required): A string representing the description of the image to be generated. Example: "amitko A man in the park face to the camera"
  • mask (optional): A URI string for the image mask used in inpainting mode.
  • seed (optional): An integer for reproducible generation.
  • image (optional): A URI string for an input image used in img2img or inpainting mode.
  • model (optional): Select between "dev" for quality or "schnell" for speed (default: "dev").
  • width (optional): Integer for image width (256 to 1440).
  • height (optional): Integer for image height (256 to 1440).
  • goFast (optional): Boolean to enable faster predictions (default: false).
  • imageFormat (optional): Output image format, either "webp", "jpg", or "png" (default: "webp").
  • imageQuality (optional): Integer for output quality (0 to 100, default: 80).
  • numberOfOutputs (optional): Integer for the number of output images (1 to 4, default: 1).
  • inferenceSteps (optional): Number of denoising steps (1 to 50, default: 28).
  • imageAspectRatio (optional): Specify aspect ratio (default: "1:1").

Here’s an example input JSON payload:

{
  "model": "dev",
  "goFast": false,
  "prompt": "amitko  A man in the park face to the camera",
  "imageFormat": "webp",
  "imageQuality": 80,
  "loraIntensity": 1,
  "inferenceSteps": 28,
  "imageResolution": "1",
  "numberOfOutputs": 1,
  "promptIntensity": 0.8,
  "imageAspectRatio": "16:9",
  "guidanceIntensity": 3,
  "additionalLoraIntensity": 1
}

Output

The output of this action is a URL to the generated image. For example:

[
  "https://assets.cognitiveactions.com/invocations/690e53ea-6bc3-4825-a4ab-76e969924596/b8f28c45-7324-457f-ab40-433061f8f78c.webp"
]

This URL points to the generated image based on the input parameters provided.

Conceptual Usage Example (Python)

Below is a conceptual Python code snippet demonstrating how a developer might call this action through a hypothetical Cognitive Actions execution endpoint:

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 = "8278fed0-4b9a-4a68-8148-7ff1f49d9d85" # Action ID for Generate Enhanced Images

# Construct the input payload based on the action's requirements
payload = {
    "model": "dev",
    "goFast": False,
    "prompt": "amitko  A man in the park face to the camera",
    "imageFormat": "webp",
    "imageQuality": 80,
    "loraIntensity": 1,
    "inferenceSteps": 28,
    "imageResolution": "1",
    "numberOfOutputs": 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 code snippet, replace YOUR_COGNITIVE_ACTIONS_API_KEY with your actual API key. The payload is structured according to the input schema, ensuring that all required parameters are included.

Conclusion

The hadasadler/amitko Cognitive Actions provide developers with a robust toolset for generating enhanced images tailored to specific requirements. By leveraging these pre-built actions, you can significantly streamline your image generation process and create high-quality visuals that enrich your applications. As you explore these capabilities, consider experimenting with various parameters to uncover the full potential of image generation in your projects.