Generate Stunning Images with batouresearch/sdxl-weighting-prompts Cognitive Actions

23 Apr 2025
Generate Stunning Images with batouresearch/sdxl-weighting-prompts Cognitive Actions

In the world of AI-driven creativity, the batouresearch/sdxl-weighting-prompts API offers powerful Cognitive Actions that enable developers to generate images with remarkable detail and precision. By leveraging the SDXL model's capabilities, you can create images using weighted prompts, refine them, and even inpaint areas for enhanced quality. This article will guide you through using the primary action available in this spec to elevate your image generation projects.

Prerequisites

Before you get started, ensure you have:

  • An API key for accessing the Cognitive Actions platform.
  • Basic knowledge of working with JSON and making HTTP requests.

To authenticate your requests, you will typically need to include your API key in the request headers. This allows you to securely access the API and utilize its features.

Cognitive Actions Overview

Generate SDXL Weighted Images

Description: This action allows you to leverage SDXL to generate images using weighted prompts with Compel's syntax. It supports multiple output images, inpainting capabilities, and refined image quality, making it an ideal choice for generating unique visuals.

Category: image-generation

Input

The input for this action consists of various parameters that define the image generation process. Here’s the schema for creating a valid request:

  • mask (string, optional): URI for the input mask used in inpaint mode. Black areas will be preserved, white areas will be inpainted.
  • seed (integer, optional): A random seed for deterministic output. Leave empty for a randomized seed. Example: 12345.
  • image (string, optional): URI of the input image for image-to-image or inpaint mode.
  • 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"): Text description of the desired output.
  • refine (string, default: "expert_ensemble_refiner"): Style used to refine the image.
  • scheduler (string, default: "K_EULER"): Algorithm used for scheduling denoising steps.
  • applyWatermark (boolean, default: true): Applies a watermark to the generated image.
  • outputImageCount (integer, default: 1, min: 1, max: 4): Number of images to generate.
  • unddesiredPrompt (string, default: ""): Elements to avoid in the generated image.
  • highNoiseFraction (number, default: 0.8): Fraction of noise used in the refinement process.
  • inferenceStepCount (integer, default: 50): Number of steps used for image denoising.
  • loraAdjustmentScale (number, default: 0.6): Scale factor for LoRA adjustments.
  • promptImpactStrength (number, default: 0.8): Strength of the prompt in img2img or inpaint modes.
  • enablePromptWeighting (boolean, default: false): Enables weighting of different components of the prompt.
  • guidanceAdjustmentScale (number, default: 7.5): Scale factor for classifier-free guidance.

Example Input:

{
  "seed": 12345,
  "width": 1024,
  "height": 1024,
  "prompt": "a legendary bird is flying under the sea water staring at a multicolor sky, wallpaper, (corals and fish are swimming around)0.4",
  "refine": "expert_ensemble_refiner",
  "scheduler": "K_EULER",
  "applyWatermark": true,
  "outputImageCount": 1,
  "unddesiredPrompt": "ugly, blurry, realistic",
  "highNoiseFraction": 0.8,
  "inferenceStepCount": 50,
  "loraAdjustmentScale": 0.6,
  "promptImpactStrength": 0.8,
  "enablePromptWeighting": true,
  "guidanceAdjustmentScale": 7.5
}

Output

When the action is executed successfully, it returns an array of generated image URLs. Here’s an example of a typical output:

Example Output:

[
  "https://assets.cognitiveactions.com/invocations/03082f6c-fedb-4288-971c-79928f623c03/2ba565dc-f472-4923-8750-f12b02eee07f.png"
]

Conceptual Usage Example (Python)

Here's a conceptual Python code snippet demonstrating how to call the Generate SDXL Weighted Images 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 = "91b15b8d-25b0-4e12-ae57-42b608c8d205" # Action ID for Generate SDXL Weighted Images

# Construct the input payload based on the action's requirements
payload = {
    "seed": 12345,
    "width": 1024,
    "height": 1024,
    "prompt": "a legendary bird is flying under the sea water staring at a multicolor sky, wallpaper, (corals and fish are swimming around)0.4",
    "refine": "expert_ensemble_refiner",
    "scheduler": "K_EULER",
    "applyWatermark": True,
    "outputImageCount": 1,
    "unddesiredPrompt": "ugly, blurry, realistic",
    "highNoiseFraction": 0.8,
    "inferenceStepCount": 50,
    "loraAdjustmentScale": 0.6,
    "promptImpactStrength": 0.8,
    "enablePromptWeighting": True,
    "guidanceAdjustmentScale": 7.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 example, the action ID and the input payload are structured based on the specifications provided. Note that the endpoint URL and request structure are illustrative and may vary based on actual implementation.

Conclusion

The batouresearch/sdxl-weighting-prompts Cognitive Actions provide developers with a powerful toolset for generating and refining images with weighted prompts. By utilizing the features offered, you can create visually stunning outputs tailored to your specifications. As you integrate these actions into your applications, consider exploring various creative use cases such as digital art, marketing visuals, and more. Happy coding!