Generate Stunning Images with the oliverobenrauch/ai-ldgrstx Cognitive Actions

21 Apr 2025
Generate Stunning Images with the oliverobenrauch/ai-ldgrstx Cognitive Actions

Integrating advanced image generation capabilities into your applications has never been easier with the oliverobenrauch/ai-ldgrstx Cognitive Actions. This API allows developers to leverage sophisticated image processing features such as image inpainting, image-to-image modifications, and prompt-based generation. The actions are optimized for both speed and quality, making them suitable for various creative and practical applications.

Prerequisites

Before getting started, ensure you have the following:

  • An API key for the Cognitive Actions platform to authenticate your requests. This key is typically passed in the headers of your API calls.
  • Familiarity with JSON and basic programming concepts, as you'll be constructing JSON payloads to interact with the API.

Cognitive Actions Overview

Generate Image with Prediction

The Generate Image with Prediction action allows you to create images based on a text prompt. This action supports various features including image inpainting and customizable settings for output format, resolution, and quality.

Input

The input for this action requires the following fields:

  • prompt (string, required): A textual description of the image you want to generate.
  • model (string, optional): Selects the inference model to use, with options like dev (performance-optimized) and schnell (speed-optimized).
  • goFast (boolean, optional): Determines if predictions should be faster (default is false).
  • numOutputs (integer, optional): Number of generated images (default is 1).
  • guidanceScale (number, optional): Controls the diffusion guidance scale (default is 3).
  • imageAspectRatio (string, optional): Defines the aspect ratio of the generated image (default is 1:1).
  • imageOutputFormat (string, optional): Specifies the format for the output image (default is webp).
  • numInferenceSteps (integer, optional): Number of denoising steps for image generation (default is 28).
  • imageOutputQuality (integer, optional): Determines the quality of the output image (default is 80).

Here’s an example JSON input payload:

{
  "model": "dev",
  "goFast": false,
  "prompt": "AILDGRSTX Ledger Stax crypto hard wallet",
  "numOutputs": 1,
  "guidanceScale": 3,
  "promptStrength": 0.8,
  "imageAspectRatio": "4:5",
  "imageOutputFormat": "png",
  "loraStrengthScale": 1,
  "numInferenceSteps": 50,
  "imageOutputQuality": 80,
  "additionalLoraScale": 1,
  "approximateMegapixels": "1"
}

Output

Upon successful execution, the action returns a list of URLs pointing to the generated images. For example:

[
  "https://assets.cognitiveactions.com/invocations/2cfdac3e-68f1-4177-9207-d05ea8ae500a/3b3de5bf-6a15-4330-9b07-b91777f22b8b.png"
]

Conceptual Usage Example (Python)

Here’s how a developer might invoke the Generate Image with Prediction action using Python. The code snippet demonstrates constructing the input JSON payload and making a request to a hypothetical 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 = "cdab06ae-f818-40d0-8582-72bb377295d3" # Action ID for Generate Image with Prediction

# Construct the input payload based on the action's requirements
payload = {
  "model": "dev",
  "goFast": False,
  "prompt": "AILDGRSTX Ledger Stax crypto hard wallet",
  "numOutputs": 1,
  "guidanceScale": 3,
  "promptStrength": 0.8,
  "imageAspectRatio": "4:5",
  "imageOutputFormat": "png",
  "loraStrengthScale": 1,
  "numInferenceSteps": 50,
  "imageOutputQuality": 80,
  "additionalLoraScale": 1,
  "approximateMegapixels": "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 for Generate Image with Prediction is specified, and the constructed payload aligns with the input requirements. Note that the endpoint URL and request structure are illustrative.

Conclusion

The oliverobenrauch/ai-ldgrstx Cognitive Actions offer a powerful way to generate images based on textual prompts, with customizable settings for output quality and format. By integrating these actions, developers can create visually stunning content tailored to their applications. Consider exploring various input configurations to unlock the full potential of this image generation capability!