Generate Stunning Custom Images with mas4low/chipelo2 Cognitive Actions

22 Apr 2025
Generate Stunning Custom Images with mas4low/chipelo2 Cognitive Actions

In today's digital landscape, the ability to generate high-quality images programmatically is invaluable for developers. The mas4low/chipelo2 Cognitive Actions provide a powerful solution for creating custom images through advanced image inpainting and transformation techniques. With options for speed optimization, customizable image attributes, and enhanced quality control, these pre-built actions streamline the image generation process, making it easy to integrate into your applications.

Prerequisites

To get started with the Cognitive Actions, you'll need an API key for the platform. This key will allow you to authenticate your requests when invoking the actions. Typically, the API key is passed in the headers of your requests to ensure secure access to the services.

Cognitive Actions Overview

Generate Custom Images

The Generate Custom Images action allows you to create custom images based on a text prompt, utilizing sophisticated models for image generation. This action is particularly useful for applications requiring unique visual content generated from user specifications.

Input

The input for this action requires a JSON object with several parameters. The only required field is the prompt. Below is an overview of the input schema:

  • prompt (required): A string that describes the image you want to generate.
  • mask: (optional) A URI string for an image mask used in inpainting mode.
  • seed: (optional) An integer for setting a random seed for reproducibility.
  • image: (optional) A URI string for an input image used in image-to-image transformations.
  • model: (optional) A string that specifies the model to use (dev or schnell).
  • width: (optional) An integer for the width of the generated image (if using custom aspect ratio).
  • height: (optional) An integer for the height of the generated image (if using custom aspect ratio).
  • goFast: (optional) A boolean to enable fast mode for speed-optimized generation.
  • aspectRatio: (optional) A string that defines the aspect ratio for the generated image.
  • numOutputs: (optional) An integer specifying the number of images to generate.
  • outputFormat: (optional) A string indicating the desired output format (e.g., webp, jpg, png).
  • guidanceScale: (optional) A number that adjusts the guidance for the diffusion process.
  • outputQuality: (optional) An integer for the quality of the output images.
  • Additional parameters such as loraScale, promptStrength, numInferenceSteps, and options for disabling the safety checker provide further customization.

Example Input:

{
  "model": "dev",
  "goFast": false,
  "prompt": "thspn, a 23 year old male, is sitting at a recording studio desk, deeply focused as he adjusts knobs on an audio mixer. He’s wearing a fitted t-shirt and chain necklace, with a pair of high-quality headphones over one ear. Behind him are glowing LED panels and a wall filled with soundproofing foam, as well as racks of equipment and a glowing laptop screen displaying a DAW (digital audio workstation). Make it realistic",
  "loraScale": 1,
  "megapixels": "1",
  "numOutputs": 1,
  "aspectRatio": "1:1",
  "outputFormat": "webp",
  "guidanceScale": 3,
  "outputQuality": 80,
  "promptStrength": 0.8,
  "numInferenceSteps": 28,
  "additionalLoraScale": 1
}

Output

The output of the Generate Custom Images action typically returns a list of URLs pointing to the generated images. Each URL can be used to access the created content directly.

Example Output:

[
  "https://assets.cognitiveactions.com/invocations/39bae9b1-ff59-44ea-a3c0-61b2c25fd1d6/e6c585a6-2fad-49b4-9c4a-f0c043c18a5c.webp"
]

Conceptual Usage Example (Python)

Here’s a conceptual example of how you might call this action using Python. This snippet demonstrates how to structure the input JSON payload correctly.

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 = "4a8b4cf4-ada2-4574-915d-dcefc8710811"  # Action ID for Generate Custom Images

# Construct the input payload based on the action's requirements
payload = {
    "model": "dev",
    "goFast": False,
    "prompt": "thspn, a 23 year old male, is sitting at a recording studio desk, deeply focused as he adjusts knobs on an audio mixer. He’s wearing a fitted t-shirt and chain necklace, with a pair of high-quality headphones over one ear. Behind him are glowing LED panels and a wall filled with soundproofing foam, as well as racks of equipment and a glowing laptop screen displaying a DAW (digital audio workstation). Make it realistic",
    "loraScale": 1,
    "megapixels": "1",
    "numOutputs": 1,
    "aspectRatio": "1:1",
    "outputFormat": "webp",
    "guidanceScale": 3,
    "outputQuality": 80,
    "promptStrength": 0.8,
    "numInferenceSteps": 28,
    "additionalLoraScale": 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 the placeholder API key and endpoint with your actual credentials. The action ID and the structured input populate the request payload, allowing the Cognitive Actions service to generate the desired images.

Conclusion

The mas4low/chipelo2 Cognitive Actions enable developers to seamlessly integrate custom image generation into their applications. With a wide range of configurable parameters, you can tailor the output to meet specific needs, enhancing the user experience with dynamic visual content. Consider experimenting with different prompts and settings to explore the full potential of these powerful actions. Happy coding!