Generate Stunning Images with the heidi-ho07/heidi_new Cognitive Actions

25 Apr 2025
Generate Stunning Images with the heidi-ho07/heidi_new Cognitive Actions

In today's digital landscape, the ability to create customized images programmatically can enhance applications in various domains, from gaming to marketing. The heidi-ho07/heidi_new specification offers a powerful set of Cognitive Actions designed for image generation, allowing developers to leverage advanced techniques such as image inpainting and image-to-image transformations. These pre-built actions simplify the process of creating high-quality images tailored to specific prompts, enabling a wide range of creative possibilities.

Prerequisites

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

  • An API key for accessing the Cognitive Actions platform.
  • Basic knowledge of JSON for structuring requests.
  • Familiarity with Python for implementing the conceptual examples provided.

Typically, authentication can be achieved by including your API key in the headers of your requests.

Cognitive Actions Overview

Generate Image with Prediction

The Generate Image with Prediction action allows you to create customized images based on textual prompts. This action supports image inpainting and transformations with various options for aspect ratios, LoRA weights, and output formats. You can choose between fast and detailed inference modes to optimize performance according to your needs.

Input

The input schema for this action requires the following fields:

  • prompt (required): A descriptive text prompt for generating images.
  • mask (optional): URI of the image mask for inpainting.
  • seed (optional): Random seed for reproducibility.
  • image (optional): URI of the input image for transformations.
  • width (optional): Width of the generated image.
  • height (optional): Height of the generated image.
  • imageFormat (optional): Format of the output image (defaults to "webp").
  • outputCount (optional): Number of images to generate (default is 1).
  • imageQuality (optional): Quality of the output image.
  • inferenceModel (optional): Select between "dev" and "schnell".
  • inferenceSteps (optional): Number of denoising steps during inference.
  • imageAspectRatio (optional): Aspect ratio for the generated images.
  • enableFastMode (optional): Toggle for fast prediction mode.
  • additionalLoraScale (optional): Extra scale factor for additional LoRA application.

Here is an example of the required input JSON payload:

{
  "prompt": "HEIDIKAKA as a real person is a big office room. HEIDIKAKA smiles in the camera. You can see in the background that something is exploding. you see some desks and lots of paper. She is happy, because the office is going to be gone in a while. She laughs and pastel confetti is flying everywhere. You can fell the happiness in this picture.",
  "imageFormat": "webp",
  "outputCount": 1,
  "imageQuality": 90,
  "mainLoraScale": 1,
  "inferenceModel": "dev",
  "inferenceSteps": 28,
  "imageAspectRatio": "1:1",
  "additionalLoraScale": 1,
  "inputPromptStrength": 0.8,
  "diffusionGuidanceScale": 2.56
}

Output

Upon a successful execution, the action returns URLs to the generated images. For instance, you might receive a response like:

[
  "https://assets.cognitiveactions.com/invocations/c988feab-6f36-49b7-b864-dce4bf8de8a9/f95ca0aa-5a72-4627-8693-8ecbdb3be88e.webp"
]

This output contains the link to the generated image, which can be used directly in your applications.

Conceptual Usage Example (Python)

Here’s a conceptual Python code snippet to invoke 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 = "ad21d671-5880-462e-bd68-79e3431f3220" # Action ID for Generate Image with Prediction

# Construct the input payload based on the action's requirements
payload = {
    "prompt": "HEIDIKAKA as a real person is a big office room. HEIDIKAKA smiles in the camera. You can see in the background that something is exploding. you see some desks and lots of paper. She is happy, because the office is going to be gone in a while. She laughs and pastel confetti is flying everywhere. You can fell the happiness in this picture.",
    "imageFormat": "webp",
    "outputCount": 1,
    "imageQuality": 90,
    "mainLoraScale": 1,
    "inferenceModel": "dev",
    "inferenceSteps": 28,
    "imageAspectRatio": "1:1",
    "additionalLoraScale": 1,
    "inputPromptStrength": 0.8,
    "diffusionGuidanceScale": 2.56
}

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, you replace YOUR_COGNITIVE_ACTIONS_API_KEY with your actual API key and define the action ID for the Generate Image with Prediction action. The payload variable structures the input JSON according to the action's specifications.

Conclusion

The heidi-ho07/heidi_new Cognitive Actions provide developers with powerful tools for generating high-quality images tailored to specific prompts. By leveraging these actions, you can enhance your applications with visually compelling content, making them more engaging for users. Consider experimenting with different input parameters to explore the full potential of image generation capabilities. Happy coding!