Create Custom Art with the cbh123/sdxl-cyanide Cognitive Action

21 Apr 2025
Create Custom Art with the cbh123/sdxl-cyanide Cognitive Action

The cbh123/sdxl-cyanide Cognitive Actions enable developers to create engaging and unique images using the SDXL model, specifically fine-tuned to emulate the playful style of "Cyanide and Happiness." These pre-built actions allow for diverse image generation capabilities, including features like img2img processing, customizable prompts, and inpainting, making it easy to integrate artistic outputs into your applications.

Prerequisites

Before you can start using the Cognitive Actions, you will need:

  • An API key for the Cognitive Actions platform. This key will typically be passed in the headers of your requests for authentication purposes.
  • Familiarity with JSON and HTTP requests, as you will need to structure your input accordingly when calling the API.

Cognitive Actions Overview

Generate Cyanide and Happiness Style Image

The Generate Cyanide and Happiness Style Image action allows you to create custom images that reflect the whimsical nature of the "Cyanide and Happiness" comic style. This action provides flexibility through various input parameters to tailor the output to your needs.

Input

The input for this action requires a JSON object that can include several fields:

  • mask (string, optional): URI of the input mask for inpainting mode.
  • seed (integer, optional): Random seed for reproducibility.
  • image (string, optional): Input image for img2img or inpaint mode.
  • width (integer, default: 1024): Width of the output image in pixels.
  • height (integer, default: 1024): Height of the output image in pixels.
  • prompt (string, default: "An astronaut riding a rainbow unicorn"): Text prompt for generating the image.
  • loraScale (number, default: 0.6): Scale for LoRA models.
  • outputCount (integer, default: 1): Number of images to generate (1 to 4).
  • refineStyle (string, default: "no_refiner"): Refinement method to use.
  • customWeights (string, optional): Specify custom LoRA weights URI.
  • guidanceScale (number, default: 7.5): Scale for classifier-free guidance.
  • applyWatermark (boolean, default: true): Enables watermarking of generated images.
  • negativePrompt (string, optional): Text prompt to exclude elements.
  • promptStrength (number, default: 0.8): Determines prompt influence in operations.
  • refinementSteps (integer, optional): Number of refinement steps for certain styles.
  • highNoiseFraction (number, default: 0.8): Fraction of noise applied in refinement.
  • numInferenceSteps (integer, default: 50): Number of denoising steps.
  • schedulingAlgorithm (string, default: "K_EULER"): Algorithm for scheduling the denoising process.
  • disableSafetyChecker (boolean, default: false): Toggle to disable the safety checker.
Example Input
{
  "width": 1024,
  "height": 1024,
  "prompt": "a blue bird on a computer in the style of TOK",
  "loraScale": 0.6,
  "outputCount": 1,
  "refineStyle": "no_refiner",
  "guidanceScale": 7.5,
  "applyWatermark": true,
  "negativePrompt": "",
  "promptStrength": 0.8,
  "highNoiseFraction": 0.8,
  "numInferenceSteps": 50,
  "schedulingAlgorithm": "K_EULER"
}

Output

The output of this action is typically a URL pointing to the generated image. For example:

[
  "https://assets.cognitiveactions.com/invocations/22279a68-706e-4459-b1a4-3d98618cf053/0609de3b-072d-4383-ac3e-d8a66b482824.png"
]

Conceptual Usage Example (Python)

Here's how you might invoke the Generate Cyanide and Happiness Style Image action using 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 = "9c642895-5de5-4908-aad8-f2d3d9c28171" # Action ID for Generate Cyanide and Happiness Style Image

# Construct the input payload based on the action's requirements
payload = {
    "width": 1024,
    "height": 1024,
    "prompt": "a blue bird on a computer in the style of TOK",
    "loraScale": 0.6,
    "outputCount": 1,
    "refineStyle": "no_refiner",
    "guidanceScale": 7.5,
    "applyWatermark": True,
    "negativePrompt": "",
    "promptStrength": 0.8,
    "highNoiseFraction": 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}")

In this code snippet, replace YOUR_COGNITIVE_ACTIONS_API_KEY with your actual API key. The input payload is structured to match the requirements of the action, and the request is sent to the hypothetical endpoint.

Conclusion

The cbh123/sdxl-cyanide Cognitive Action provides a powerful tool for developers looking to integrate creative image generation capabilities into their applications. With various customization options and flexibility, you can bring unique artistic styles to life effortlessly. Consider exploring additional use cases such as game design, graphic novels, or even personalized content for social media. Happy coding!