Generate Stunning Images with Speedy SDXL Cognitive Actions

24 Apr 2025
Generate Stunning Images with Speedy SDXL Cognitive Actions

In today's digital landscape, the demand for high-quality image generation is on the rise. The Speedy SDXL Cognitive Actions provide developers with powerful tools to create stunning images quickly and efficiently. Leveraging the SDXL model, these actions come equipped with customizable options for dimensions, refinement styles, and more, enabling you to generate images that meet your specific needs effortlessly.

Prerequisites

Before diving into the integration of Speedy SDXL Cognitive Actions, ensure you have the following:

  • An API key for the Cognitive Actions platform, which will be used for authentication.
  • Basic knowledge of JSON for structuring requests and handling responses.
  • A programming environment set up for making HTTP requests, such as Python with the requests library.

To authenticate your requests, you will need to include your API key in the request headers, typically structured as follows:

Authorization: Bearer YOUR_COGNITIVE_ACTIONS_API_KEY

Cognitive Actions Overview

Generate Image with Speedy SDXL

The Generate Image with Speedy SDXL action allows you to create images using the SDXL model quickly. This action offers a variety of customization options, including image dimensions, refinement styles, scheduling algorithms, and more.

Input

The input for this action is structured as follows:

{
  "seed": 12345,
  "width": 1024,
  "height": 1024,
  "prompt": "An astronaut riding a rainbow unicorn",
  "refine": "no_refiner",
  "scheduler": "K_EULER",
  "addWatermark": true,
  "guidanceFactor": 7.5,
  "numberOfOutputs": 1,
  "highNoiseFraction": 0.8,
  "inputPromptStrength": 0.8,
  "negativeInputPrompt": "",
  "numberOfInferenceSteps": 50
}
  • seed: (optional) An integer to initialize the random number generator; leaving it blank will randomize the seed.
  • width: (required) The width of the output image in pixels (default is 1024).
  • height: (required) The height of the output image in pixels (default is 1024).
  • prompt: (required) A textual description to guide image generation (default is "An astronaut riding a rainbow unicorn").
  • refine: (optional) Specifies the refinement technique to enhance the image (default is "no_refiner").
  • scheduler: (optional) The scheduling algorithm for image generation (default is "K_EULER").
  • addWatermark: (optional) Determines if a watermark is applied to generated images (default is true).
  • guidanceFactor: (optional) The influence of the classifier-free guidance over image generation, ranging from 1 to 50 (default is 7.5).
  • numberOfOutputs: (optional) Specifies the number of images to generate (default is 1, maximum 4).
  • highNoiseFraction: (optional) For 'expert_ensemble_refiner', indicates the proportion of noise to include (default is 0.8).
  • inputPromptStrength: (optional) Determines the degree of prompt influence in processes (default is 0.8).
  • negativeInputPrompt: (optional) A textual prompt to specify elements to minimize in the generated image (default is empty).
  • numberOfInferenceSteps: (optional) Specifies the number of denoising steps in image generation (default is 50).

Output

Upon execution, the action typically returns a URL pointing to the generated image, for example:

[
  "https://assets.cognitiveactions.com/invocations/444e66cd-96c8-48dd-8cec-20281c967a39/1424cdfd-6316-4c79-9997-00a8ab94722e.png"
]

Conceptual Usage Example (Python)

Here’s a conceptual example of how you might call the Generate Image with Speedy SDXL 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 = "da5fe884-3aeb-4589-9028-5542d87b445f"  # Action ID for Generate Image with Speedy SDXL

# Construct the input payload based on the action's requirements
payload = {
    "width": 1024,
    "height": 1024,
    "prompt": "An astronaut riding a rainbow unicorn",
    "refine": "no_refiner",
    "scheduler": "K_EULER",
    "addWatermark": True,
    "guidanceFactor": 7.5,
    "numberOfOutputs": 1,
    "highNoiseFraction": 0.8,
    "inputPromptStrength": 0.8,
    "negativeInputPrompt": "",
    "numberOfInferenceSteps": 50
}

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 input payload are specified, and a POST request is made to the hypothetical Cognitive Actions execution endpoint. The response will contain the URL of the generated image, which you can then use as needed.

Conclusion

The Speedy SDXL Cognitive Actions empower developers to generate high-quality images quickly and with precision. By leveraging the multitude of customizable options provided, you can create images that perfectly align with your vision. Whether you're enhancing user experiences in apps, generating content for marketing, or exploring creative projects, these actions offer a robust solution.

Explore the possibilities of image generation with Speedy SDXL and start innovating today!