Transform Your Artwork with the SDXL Alla Prima Image Generation Action

24 Apr 2025
Transform Your Artwork with the SDXL Alla Prima Image Generation Action

In the world of digital creativity, the ability to generate stunning images programmatically can greatly enhance your applications. The SDXL Alla Prima Cognitive Action, part of the doriandarko/sdxl-allaprima spec, provides developers with a powerful tool for generating images in a vibrant and blocky alla prima style. This action leverages a sophisticated SDXL model trained on a carefully curated dataset, allowing for various creative possibilities through customizable parameters.

Prerequisites

To get started with the SDXL Alla Prima image generation action, you will need access to the Cognitive Actions platform, which typically requires an API key for authentication. This API key should be included in the request headers when making calls to the Cognitive Actions endpoint.

Authorization: Bearer YOUR_COGNITIVE_ACTIONS_API_KEY

Cognitive Actions Overview

Generate Image in Alla Prima Style

The Generate Image in Alla Prima Style action enables the creation of unique images by utilizing the SDXL model. It's designed to reproduce artwork in a colorful, blocky style, making it suitable for various artistic applications. This action includes options for image-to-image (img2img) processing and inpainting, allowing for refined outputs through adjustable parameters.

Input

The action takes a well-defined input schema. Below are the required and optional fields:

  • prompt (string): Textual input for generating the image. Defaults to "An astronaut riding a rainbow unicorn".
  • width (integer): Output image width in pixels. Default is 1024.
  • height (integer): Output image height in pixels. Default is 1024.
  • scheduler (string): Algorithm for scheduling denoising steps. Default is "K_EULER".
  • guidanceScale (number): Scale factor for classifier-free guidance. Ranges from 1 to 50, defaults to 7.5.
  • promptStrength (number): Strength of the prompt in img2img or inpaint. Ranges from 0 to 1, defaults to 0.8.
  • numberOfOutputs (integer): Number of images to generate, ranging from 1 to 4. Defaults to 1.
  • refinementStyle (string): Style of refinement applied to the image. Defaults to "no_refiner".
  • watermarkEnabled (boolean): Whether to apply a watermark. Defaults to true.
  • highNoiseFraction (number): Fraction of high-frequency noise for expert refiner. Ranges from 0 to 1.
  • loraAdditiveScale (number): Scale for LoRA adjustments, applicable only to trained models. Ranges from 0 to 1.
  • inferenceStepsCount (integer): Number of denoising steps during image generation. Defaults to 50.

Example Input

Here is an example of the JSON payload required to invoke this action:

{
  "width": 1024,
  "height": 1024,
  "prompt": "In the style of PRIMSL, a blue bowl and slice of oranges on a table",
  "scheduler": "K_EULER",
  "guidanceScale": 7.5,
  "promptStrength": 0.8,
  "numberOfOutputs": 1,
  "refinementStyle": "no_refiner",
  "watermarkEnabled": true,
  "highNoiseFraction": 0.8,
  "loraAdditiveScale": 0.6,
  "inferenceStepsCount": 50
}

Output

Upon successful execution, the action returns a URL pointing to the generated image. Here’s an example of the output:

[
  "https://assets.cognitiveactions.com/invocations/6594a850-06bc-42a6-97c9-5dc6a92b862f/ed8c9112-2534-4848-b524-ff07fca141af.png"
]

Conceptual Usage Example (Python)

The following Python code snippet demonstrates how to call the SDXL Alla Prima action using a hypothetical Cognitive Actions execution endpoint:

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 = "b8a8f9d7-9f9e-4f7d-b6f4-b71e7418d6fe"  # Action ID for Generate Image in Alla Prima Style

# Construct the input payload based on the action's requirements
payload = {
    "width": 1024,
    "height": 1024,
    "prompt": "In the style of PRIMSL, a blue bowl and slice of oranges on a table",
    "scheduler": "K_EULER",
    "guidanceScale": 7.5,
    "promptStrength": 0.8,
    "numberOfOutputs": 1,
    "refinementStyle": "no_refiner",
    "watermarkEnabled": true,
    "highNoiseFraction": 0.8,
    "loraAdditiveScale": 0.6,
    "inferenceStepsCount": 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 code snippet, replace the placeholders with your actual API key and endpoint. The action ID and the input payload are structured according to the requirements outlined in the action's schema.

Conclusion

The SDXL Alla Prima image generation action offers a fantastic opportunity for developers to create unique and stylized images programmatically. With its robust input parameters and customizable options, you can tailor the generation process to meet your specific artistic needs. Whether you're looking to enhance creative applications or experiment with digital art, this action provides a powerful tool at your disposal. Explore the potential of the SDXL model and start generating your masterpieces today!