Unlocking Image Generation with daargo44/amti13 Cognitive Actions

23 Apr 2025
Unlocking Image Generation with daargo44/amti13 Cognitive Actions

In the world of AI and machine learning, the ability to generate high-quality images from textual descriptions is a game changer. The daargo44/amti13 Cognitive Actions offer developers a powerful toolset for image generation and transformation tasks. With a focus on flexibility and efficiency, these pre-built actions enable a wide range of creative possibilities, from inpainting to predictive rendering. In this article, we will explore the Generate Image with Prediction action in detail, including its capabilities, input requirements, expected output, and a conceptual usage example.

Prerequisites

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

  • An API key for the Cognitive Actions platform. This key is essential for authenticating your requests.
  • Familiarity with JSON format, as inputs and outputs will be structured accordingly.

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

Cognitive Actions Overview

Generate Image with Prediction

The Generate Image with Prediction action facilitates the generation and transformation of images using a flexible schema known as CompositeRequest. This action supports various settings, including model selection for detailed or faster rendering, customizable image dimensions, and output formats.

Input

The input for this action is defined by the CompositeRequest schema, which includes several fields:

  • prompt (required): A text prompt guiding the image generation.
  • mask (optional): Image mask for inpainting mode.
  • seed (optional): Random seed for consistent results.
  • model (optional): Choose between dev for detailed images or schnell for faster results.
  • width and height (optional): Specify dimensions for the image (effective only with custom aspect ratios).
  • aspectRatio (optional): Determines the aspect ratio of the output image.
  • guidanceScale (optional): Controls the impact of the prompt during generation.
  • numberOfOutputs (optional): Specifies how many images to generate.
  • imageOutputFormat (optional): Choose the format of the output images (e.g., webp, jpg, png).
  • imageOutputQuality (optional): Sets the quality of the output images.

Here’s an example of the JSON payload for invoking this action:

{
  "model": "dev",
  "prompt": "cinematic view: amti13, the 12 year old boy with glasses wearing Indiana Jones hat, is arguing with an 80 year old Jewish Rabbi with a long white beard from the 12th century, inside a synagogue in ancient Egypt",
  "aspectRatio": "16:9",
  "guidanceScale": 3.5,
  "loraIntensity": 1,
  "promptStrength": 0.8,
  "numberOfOutputs": 1,
  "imageOutputFormat": "webp",
  "imageOutputQuality": 90,
  "numberOfInferenceSteps": 28,
  "additionalLoraIntensity": 1
}

Output

The action typically returns a URL pointing to the generated image. For instance, a successful output could look like this:

[
  "https://assets.cognitiveactions.com/invocations/1ab22b54-be59-4da9-bdfd-ecc423cc1235/a6695323-7d9c-44c0-af4a-ba6d08aec1f6.webp"
]

Conceptual Usage Example (Python)

Below is a conceptual Python code snippet that demonstrates how to call the Generate Image with Prediction 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 = "ec513f26-727b-4d17-9421-a50de8c060e3" # Action ID for Generate Image with Prediction

# Construct the input payload based on the action's requirements
payload = {
    "model": "dev",
    "prompt": "cinematic view: amti13, the 12 year old boy with glasses wearing Indiana Jones hat, is arguing with an 80 year old Jewish Rabbi with a long white beard from the 12th century, inside a synagogue in ancient Egypt",
    "aspectRatio": "16:9",
    "guidanceScale": 3.5,
    "loraIntensity": 1,
    "promptStrength": 0.8,
    "numberOfOutputs": 1,
    "imageOutputFormat": "webp",
    "imageOutputQuality": 90,
    "numberOfInferenceSteps": 28,
    "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 action ID is set to the ID corresponding to the Generate Image with Prediction action. The input payload is constructed based on the specifications, and the request is sent to a hypothetical endpoint.

Conclusion

The daargo44/amti13 Cognitive Actions provide an exciting avenue for developers to explore image generation and transformation capabilities. By leveraging the Generate Image with Prediction action, you can create stunning visuals from text prompts with customizable settings. Whether you're working on a creative project or exploring new AI technologies, these actions are designed to enhance your application's capabilities.

Consider experimenting with different prompts and configurations to unlock the full potential of image generation! Happy coding!