Create Stunning Themed Images with cbh123/sdxl-nightmare Cognitive Actions

21 Apr 2025
Create Stunning Themed Images with cbh123/sdxl-nightmare Cognitive Actions

The cbh123/sdxl-nightmare API offers developers powerful Cognitive Actions that leverage advanced image generation capabilities. With a focus on creating themed visuals, this API allows you to generate captivating images based on customizable prompts and settings. By using these pre-built actions, developers can save time and effort while integrating sophisticated image generation functionalities into their applications.

Prerequisites

To use the Cognitive Actions provided by the cbh123/sdxl-nightmare spec, you will need:

  • An API key for the Cognitive Actions platform.
  • Basic knowledge of making HTTP requests and handling JSON payloads.

Conceptually, authentication typically involves passing your API key in the request headers. This key ensures that your application has permission to utilize the Cognitive Actions.

Cognitive Actions Overview

Generate Nightmare Before Christmas Themed Image

This action generates images using an SDXL model that has been fine-tuned on "The Nightmare Before Christmas." It allows for extensive customization through various parameters to produce unique themed visuals.

Input

The input for this action follows the CompositeRequest schema and includes multiple fields:

  • mask (string, optional): URI of the input mask for inpainting.
  • seed (integer, optional): Random seed for image generation.
  • image (string, optional): URI of the input image for image-to-image or inpainting processing.
  • width (integer, default: 1024): The width of the output image in pixels.
  • height (integer, default: 1024): The height of the output image in pixels.
  • prompt (string, default: "An astronaut riding a rainbow unicorn"): Creative input prompt to guide image generation.
  • loraScale (number, default: 0.6): LoRA scale for image generation.
  • refineStyle (string, default: "no_refiner"): The refinement style to be used in image processing.
  • guidanceScale (number, default: 7.5): Control scale for classifier-free guidance.
  • applyWatermark (boolean, default: true): Indicates if a watermark should be applied.
  • negativePrompt (string, optional): Negative input prompt to exclude specific elements from generation.
  • promptStrength (number, default: 0.8): Strength of the prompt for image processing.
  • outputImageCount (integer, default: 1): Number of images to generate (1 to 4).
  • highNoiseFraction (number, default: 0.8): Fraction of noise to apply in refinement.
  • numInferenceSteps (integer, default: 50): Total number of denoising steps during image generation.
  • processingScheduler (string, default: "K_EULER"): The algorithm used for processing steps.
  • disableSafetyChecker (boolean, default: false): Option to disable the safety checker for generated images.

Example Input:

{
  "width": 768,
  "height": 768,
  "prompt": "a cat in the style of TOK",
  "loraScale": 0.6,
  "refineStyle": "no_refiner",
  "guidanceScale": 7.5,
  "applyWatermark": true,
  "negativePrompt": "",
  "promptStrength": 0.8,
  "outputImageCount": 1,
  "highNoiseFraction": 0.8,
  "numInferenceSteps": 50,
  "processingScheduler": "K_EULER"
}

Output

The action typically returns an array of image URLs. Each URL points to a generated image based on the provided input parameters.

Example Output:

[
  "https://assets.cognitiveactions.com/invocations/e75c2bf5-3b88-4576-9f33-0f36a2b866df/90bc0e64-9457-4557-aceb-e42477863ee0.png"
]

Conceptual Usage Example (Python)

Here’s a conceptual Python code snippet demonstrating how to call this 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 = "b431d79f-ce18-4734-92e7-9eb8c1c88286"  # Action ID for Generate Nightmare Before Christmas Themed Image

# Construct the input payload based on the action's requirements
payload = {
    "width": 768,
    "height": 768,
    "prompt": "a cat in the style of TOK",
    "loraScale": 0.6,
    "refineStyle": "no_refiner",
    "guidanceScale": 7.5,
    "applyWatermark": True,
    "negativePrompt": "",
    "promptStrength": 0.8,
    "outputImageCount": 1,
    "highNoiseFraction": 0.8,
    "numInferenceSteps": 50,
    "processingScheduler": "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 snippet, replace YOUR_COGNITIVE_ACTIONS_API_KEY with your actual API key. The payload variable contains the input structured according to the action's requirements. The endpoint URL and request format shown are illustrative.

Conclusion

The cbh123/sdxl-nightmare Cognitive Actions provide developers with a robust way to generate themed images effortlessly. With flexible input parameters for customization, you can create unique visuals tailored to your application's needs. Consider exploring additional use cases, such as using different prompts or settings, to maximize the potential of these image generation capabilities. Happy coding!