Create Stunning Images with WAI-NSFW Illustrious Cognitive Actions

23 Apr 2025
Create Stunning Images with WAI-NSFW Illustrious Cognitive Actions

In recent years, the demand for high-quality image generation has surged, with developers seeking tools to create custom visuals based on specific prompts. The WAI-NSFW Illustrious Cognitive Actions provide a powerful API for generating images using advanced models, specifically tailored for nuanced image creation. By leveraging the capabilities of this set of actions, developers can enhance their applications with unique image generation features that cater to various needs.

Prerequisites

Before diving into the integration of the WAI-NSFW Illustrious Cognitive Actions, you'll need to ensure you have access to the Cognitive Actions platform. You will require an API key for authentication, which is typically passed in the headers of your API requests. This allows you to securely access the functionalities provided by the API.

Cognitive Actions Overview

Generate Image with WAI-NSFW Illustrious

The Generate Image with WAI-NSFW Illustrious action is designed to produce high-quality images based on user-defined prompts and customizable parameters. This action falls under the category of image-generation and utilizes the WAI-NSFW-illustrious-SDXL-v11 model.

Input

The input schema for this action requires several fields, allowing for detailed control over the image generation process:

  • seed (integer, default: -1): The seed for generation; set to -1 for a random seed.
  • model (string, default: "WAI-NSFW-illustrious-SDXL-v11"): Specifies the model to use.
  • steps (integer, default: 30): The number of steps for image generation, ranging from 1 to 100.
  • width (integer, default: 1024): The width of the generated image in pixels (1 to 4096).
  • height (integer, default: 1024): The height of the generated image in pixels (1 to 4096).
  • prompt (string, default: "street, 1girl, dark-purple short hair, purple eyes..."): The image generation prompt.
  • pagScale (number, default: 3): Sets the PAG scale, compatible with CFG.
  • scheduler (string, default: "Euler a"): The scheduler algorithm for generation.
  • configScale (number, default: 7): Controls the CFG scale for adherence to the prompt.
  • addPreprompt (boolean, default: true): Whether to prepend a predefined preprompt.
  • clipLayerSkip (integer, default: 2): Number of CLIP layers to skip.
  • imageBatchSize (integer, default: 1): Number of images to generate per batch (1 to 4).
  • undesirablePrompt (string, default: "nsfw, naked"): Elements to avoid in the image.
  • visualAutoencoder (string, default: "default"): The Variational Autoencoder to use.
  • guidanceNoiseRescale (number, default: 0.5): Factor for rescaling CFG-generated noise.

Example Input:

{
  "seed": -1,
  "model": "WAI-NSFW-illustrious-SDXL-v11",
  "steps": 30,
  "width": 1024,
  "height": 1024,
  "prompt": "street, 1girl, dark-purple short hair, purple eyes, medium breasts, cleavage, casual clothes, smile, V",
  "pagScale": 3,
  "scheduler": "Euler a",
  "configScale": 7,
  "addPreprompt": true,
  "clipLayerSkip": 2,
  "imageBatchSize": 1,
  "undesirablePrompt": "nsfw, naked",
  "visualAutoencoder": "default",
  "guidanceNoiseRescale": 0.5
}

Output

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

Example Output:

[
  "https://assets.cognitiveactions.com/invocations/de4d230e-a8a6-432b-bfa3-c6674ed647b7/dbd394d2-2188-4ece-8e44-9dd2c8c3cf23.png"
]

Conceptual Usage Example (Python)

Here is a conceptual example of how you might implement a call to the WAI-NSFW Illustrious 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 = "0d73198d-9667-42f5-9bfb-1d50ced1f9d6" # Action ID for Generate Image with WAI-NSFW Illustrious

# Construct the input payload based on the action's requirements
payload = {
  "seed": -1,
  "model": "WAI-NSFW-illustrious-SDXL-v11",
  "steps": 30,
  "width": 1024,
  "height": 1024,
  "prompt": "street, 1girl, dark-purple short hair, purple eyes, medium breasts, cleavage, casual clothes, smile, V",
  "pagScale": 3,
  "scheduler": "Euler a",
  "configScale": 7,
  "addPreprompt": True,
  "clipLayerSkip": 2,
  "imageBatchSize": 1,
  "undesirablePrompt": "nsfw, naked",
  "visualAutoencoder": "default",
  "guidanceNoiseRescale": 0.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 snippet, replace YOUR_COGNITIVE_ACTIONS_API_KEY with your actual API key and ensure the endpoint URL is correct. The action ID and input payload are structured according to the specifications discussed.

Conclusion

Integrating the WAI-NSFW Illustrious Cognitive Actions into your applications allows you to harness the power of sophisticated image generation tailored to your specific needs. By following the guidelines and examples provided, you can easily implement this functionality and enhance your projects with high-quality visuals. Explore further use cases, and start creating stunning images today!