Create Stunning Images with BetterUp's Stable Diffusion XL Cognitive Actions

24 Apr 2025
Create Stunning Images with BetterUp's Stable Diffusion XL Cognitive Actions

In the world of AI-driven creativity, generating high-quality images has become easier and more customizable than ever before. The mauricioalarcon/sdlx-bu spec provides a powerful Cognitive Action—Generate Image with BetterUp Stable Diffusion XL—that leverages the Stable Diffusion XL Image Model to create vibrant, engaging visuals. This action allows developers to tailor images to their specifications, enhancing them with attributes like color palette, image dimensions, and more. Let’s dive into how you can integrate this action into your applications.

Prerequisites

Before you get started with the Cognitive Actions, ensure you have the following:

  • An API key for the Cognitive Actions platform.
  • Basic knowledge of making HTTP requests and handling JSON data.
  • Familiarity with Python for executing the conceptual usage examples.

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

Cognitive Actions Overview

Generate Image with BetterUp Stable Diffusion XL

The Generate Image with BetterUp Stable Diffusion XL action allows you to create stunning images that reflect your imagination. By customizing various parameters, you can achieve unique visual outputs tailored to your specifications.

Input

The action accepts a JSON payload structured as follows:

{
  "width": 1024,
  "height": 1024,
  "prompt": "In the style of BetterUp, a captain sailing the ocean on a ship with a lighthouse in the background, with a vibrant, high contrast color palette, use rubine colors as a highlight",
  "loraScale": 0.6,
  "numOutputs": 1,
  "refineStyle": "no_refiner",
  "guidanceScale": 7.5,
  "highNoiseFrac": 0.8,
  "applyWatermark": true,
  "negativePrompt": "",
  "promptStrength": 0.8,
  "numInferenceSteps": 50,
  "workflowScheduler": "K_EULER"
}
  • Width & Height: Output image dimensions in pixels (default is 1024).
  • Prompt: The textual input guiding the image generation.
  • LoRA Scale: A scale for LoRA additive effects (0 to 1).
  • Num Outputs: Number of images to generate (1 to 4).
  • Refine Style: Determines the refinement style for image generation.
  • Guidance Scale: Classifier-free guidance scale (1 to 50).
  • High Noise Fraction: Fraction of noise applied in refinement.
  • Apply Watermark: Whether to add a watermark to the image.
  • Negative Prompt: Directs the generation away from unwanted concepts.
  • Prompt Strength: Strength of the prompt for transformations (0 to 1).
  • Num Inference Steps: Total denoising steps (1 to 500).
  • Workflow Scheduler: Manages the generation process with various options.
  • Disable Safety Checker: Option to disable safety checks.

Output

The action typically returns a JSON array containing URLs of the generated images. For example:

[
  "https://assets.cognitiveactions.com/invocations/66a96c98-72e7-4720-ad76-1f62d55c245b/65d1c547-2617-4cfe-949d-b7cb1537aa27.png"
]

This URL links directly to the generated image.

Conceptual Usage Example (Python)

Here’s how you might implement this action in Python:

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 = "567f0d18-7335-43ad-8014-4095a59d0b8f"  # Action ID for Generate Image with BetterUp Stable Diffusion XL

# Construct the input payload based on the action's requirements
payload = {
    "width": 1024,
    "height": 1024,
    "prompt": "In the style of BetterUp, a captain sailing the ocean on a ship with a lighthouse in the background, with a vibrant, high contrast color palette, use rubine colors as a highlight",
    "loraScale": 0.6,
    "numOutputs": 1,
    "refineStyle": "no_refiner",
    "guidanceScale": 7.5,
    "highNoiseFrac": 0.8,
    "applyWatermark": True,
    "negativePrompt": "",
    "promptStrength": 0.8,
    "numInferenceSteps": 50,
    "workflowScheduler": "K_EULER"
}

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 endpoint URL and API key with your own. The payload is structured to match the input schema requirements, ensuring that the generated images meet your specifications.

Conclusion

The Generate Image with BetterUp Stable Diffusion XL action offers a versatile solution for developers looking to create stunning, customized images effortlessly. By leveraging this Cognitive Action, you can enhance your applications with beautiful visuals tailored to your creative vision. Next, explore how you can integrate more Cognitive Actions or refine your image generation workflows to create even more impactful user experiences.