Create Stunning Images with BetterUp Cognitive Actions

24 Apr 2025
Create Stunning Images with BetterUp Cognitive Actions

In the world of AI-driven creativity, the jasonljin/sdxl-betterup specification empowers developers to harness the capabilities of the BetterUp Stable Diffusion XL model for image generation. With a range of customizable options, these Cognitive Actions allow you to create unique images tailored to your specific needs. Whether you're looking to generate imaginative artwork or refine existing images, these pre-built actions simplify the integration process, enabling you to focus on creativity rather than complexity.

Prerequisites

Before diving into the integration of Cognitive Actions, you will need a few essentials:

  • API Key: You must have an API key to authenticate your requests to the Cognitive Actions platform. This key will be included in the request headers.
  • Basic Understanding of JSON: Familiarity with JSON format will help you structure your input data correctly.

The authentication process typically involves passing your API key in the headers of your requests, ensuring secure access to the action endpoints.

Cognitive Actions Overview

Generate BetterUp Style Image

Purpose: This action allows you to create images using the BetterUp Stable Diffusion XL model. You can customize aspects such as size, style, and refinement options for enhanced quality.

Category: image-generation

Input

The input schema for this action requires the following fields:

  • prompt (string): Describes the desired output image.
  • width (integer): Specifies the width of the output image (default: 1024).
  • height (integer): Specifies the height of the output image (default: 1024).
  • numOutputs (integer): Number of images to generate (1 to 4, default: 1).
  • guidanceScale (number): Classifier-free guidance scale (range: 1 to 50, default: 7.5).
  • loraScale (number): Scale factor for LoRA (range: 0 to 1, default: 0.6).
  • numInferenceSteps (integer): Total number of denoising steps (1 to 500, default: 50).
  • schedulingAlgorithm (string): Algorithm for scheduling denoising steps (default: "K_EULER").
  • applyWatermark (boolean): Indicates if a watermark should be applied (default: true).
  • negativePrompt (string): Features to avoid in the output.
  • promptStrength (number): Influence of the prompt when using img2img or inpainting (range: 0 to 1, default: 0.8).
  • Additional optional fields include seed, mask, image, refineStyle, highNoiseFrac, loraWeights, and refineSteps.

Here’s an example of the input 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,
  "schedulingAlgorithm": "K_EULER"
}

Output

The action typically returns a list of URIs pointing to the generated images. For example:

[
  "https://assets.cognitiveactions.com/invocations/ab9dd102-8aca-4ca9-9480-f9fb717428d2/0fe85a23-b2c4-422b-b0e7-fe792f4e89b9.png"
]

This output provides the link to the created image, which you can then use in your application.

Conceptual Usage Example (Python)

Here’s a conceptual Python code snippet demonstrating how to invoke the Generate BetterUp Style Image 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 = "8dd13f26-bb36-4b45-94cf-c585d474627d"  # Action ID for Generate BetterUp Style Image

# 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,
    "schedulingAlgorithm": "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}")

This code demonstrates how to construct the input payload, set up the headers for authentication, and handle the response. Make sure to substitute your API key and endpoint accordingly.

Conclusion

The jasonljin/sdxl-betterup Cognitive Actions offer a powerful way to generate and customize images with ease. By leveraging the BetterUp Stable Diffusion XL model, developers can create stunning visuals tailored to their applications. Whether for artistic projects, marketing campaigns, or any creative endeavor, these actions provide the tools necessary to bring your ideas to life. Start experimenting with these actions today to unlock new possibilities in image generation!