Create Stunning Images with the cesarvega/my-heiny-model Cognitive Actions

24 Apr 2025
Create Stunning Images with the cesarvega/my-heiny-model Cognitive Actions

In today’s digital landscape, the ability to generate high-quality images programmatically can add significant value to applications. The cesarvega/my-heiny-model provides a powerful set of Cognitive Actions that enable developers to create images using advanced techniques such as inpainting and image-to-image transformations. These pre-built actions simplify the process of image generation, allowing developers to focus on crafting engaging user experiences rather than building complex image processing algorithms from scratch.

Prerequisites

Before you start using the Cognitive Actions, ensure you have the following:

  • An API key for the Cognitive Actions platform to authenticate your requests.
  • Basic knowledge of JSON and how to work with RESTful APIs.

Authentication typically involves passing your API key in the request headers, allowing you to securely access the actions provided by the service.

Cognitive Actions Overview

Generate Image with Custom Parameters

The Generate Image with Custom Parameters action allows you to create high-quality images by providing custom parameters for image generation. It supports various models optimized for different prediction speeds and allows you to control image dimensions, refine details, and employ advanced techniques.

Input

The input schema for this action includes a variety of fields, some of which are required while others are optional. The primary required field is the prompt, which defines the image content. Below are the details of the input schema:

  • prompt (required): A string that provides the text description for the image.
    Example: "Generate a photo of HEINY posing in a glamorous beach photoshoot."
  • model (optional): Selects the model for inference, with options like "dev" and "schnell".
  • image (optional): A URI of an input image for image-to-image transformation.
  • mask (optional): A URI for an image mask used in inpainting mode.
  • width (optional): Specifies the width of the generated image (256 to 1440).
  • height (optional): Specifies the height of the generated image (256 to 1440).
  • accelerate (optional): A boolean to enable fast mode.
  • imageFormat (optional): Format of the output image (e.g., "webp", "jpg", "png").
  • imageQuality (optional): Quality level for output images (0 to 100).
  • guidanceScale (optional): A number indicating how closely the output should follow the prompt.
  • numberOfOutputs (optional): The number of images to generate (1 to 4).

Example Input JSON:

{
  "model": "dev",
  "prompt": "Generate a photo of HEINY posing in a glamorous beach photoshoot, wearing a shimmering bikini with a flowing sheer cover-up, standing against the backdrop of an exotic tropical paradise at sunset.",
  "accelerate": false,
  "imageFormat": "webp",
  "imageQuality": 89,
  "guidanceScale": 3,
  "loraIntensity": 1,
  "imageResolution": "1",
  "numberOfOutputs": 1,
  "promptIntensity": 0.83,
  "imageAspectRatio": "1:1",
  "numberOfInferenceSteps": 50,
  "additionalLoraIntensity": 1.5
}

Output

The action typically returns a URL pointing to the generated image.

Example Output:

[
  "https://assets.cognitiveactions.com/invocations/fe74a7b9-637d-4488-bcd9-3597bfb926e9/cc9fbe1a-62e3-41d9-b194-2d20224e0e54.webp"
]

Conceptual Usage Example (Python)

Below is a conceptual Python code snippet illustrating how to invoke the Generate Image with Custom Parameters 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 = "42715295-13d8-43b8-a4a5-6954996ae0d7" # Action ID for Generate Image with Custom Parameters

# Construct the input payload based on the action's requirements
payload = {
    "model": "dev",
    "prompt": "Generate a photo of HEINY posing in a glamorous beach photoshoot, wearing a shimmering bikini with a flowing sheer cover-up, standing against the backdrop of an exotic tropical paradise at sunset.",
    "accelerate": False,
    "imageFormat": "webp",
    "imageQuality": 89,
    "guidanceScale": 3,
    "loraIntensity": 1,
    "imageResolution": "1",
    "numberOfOutputs": 1,
    "promptIntensity": 0.83,
    "imageAspectRatio": "1:1",
    "numberOfInferenceSteps": 50,
    "additionalLoraIntensity": 1.5
}

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, replace YOUR_COGNITIVE_ACTIONS_API_KEY with your actual API key. The payload variable is structured according to the action's input schema. The API response provides the generated image URL upon successful execution.

Conclusion

The cesarvega/my-heiny-model Cognitive Actions offer developers an accessible way to generate stunning images. With customizable parameters and advanced techniques at your disposal, you can create unique visuals tailored to your application's needs. Start experimenting with the action today to unlock creative possibilities in your projects!