Elevate Your Applications with Image Generation Using Good SDXL Models and LoRAs

22 Apr 2025
Elevate Your Applications with Image Generation Using Good SDXL Models and LoRAs

In the ever-evolving world of AI and machine learning, image generation has become a pivotal feature in many applications. The goodguy1963/good-sdxl-models-plus-loras API offers a powerful set of Cognitive Actions that allow developers to harness advanced image generation capabilities. These actions provide pre-built functionalities such as text-to-image conversion, image processing, and inpainting, making it easier for developers to create visually stunning outputs.

Prerequisites

Before diving into the implementation of these Cognitive Actions, ensure you have the following:

  • An API key for the Cognitive Actions platform.
  • Basic understanding of how to make API calls and manage JSON data.
  • Familiarity with concepts of image generation and manipulation.

Authentication typically involves passing your API key in the headers of your requests, allowing you to securely access the Cognitive Actions.

Cognitive Actions Overview

Generate Image with SDXL Models

The Generate Image with SDXL Models action is designed to create high-quality images using SDXL models and LoRAs. It supports various functionalities, including text-to-image conversion and inpainting, making it a versatile tool for developers.

Input

The input schema consists of several fields, both required and optional. Here’s a breakdown:

  • prompt (string): Describes the desired outcome (required).
  • width (integer): Specifies the width of the output image in pixels (default: 768).
  • height (integer): Specifies the height of the output image in pixels (default: 768).
  • sampler (string): Selects the sampling algorithm for generation (default: "DPMSolverMultistep").
  • modelName (string): Specifies the model to be used for generation (default: "realvisxl_v50_sg161222").
  • layerWeight (number): Degree to which layers affect the output (default: 0.8).
  • guidanceScale (number): Impact of text guidance on the output image (default: 7.5).
  • negativePrompt (string): Lists undesired features to eliminate from the output.
  • instructionStrength (number): Initial prompt strength if using an init image (default: 0.8).
  • numberOfInferenceSteps (integer): Sets the number of denoising steps (default: 30).

Here’s a practical example of the JSON payload:

{
  "width": 1024,
  "height": 1024,
  "prompt": "magical Castel",
  "sampler": "DPMPP_2M",
  "modelName": "cyberrealistic_xl_cyberdelia",
  "layerWeight": 0.8,
  "guidanceScale": 7.5,
  "negativePrompt": "worst quality, low quality, normal quality, lowres, low details, oversaturated...",
  "instructionStrength": 0.8,
  "numberOfInferenceSteps": 30
}

Output

Upon successful execution, this action typically returns a URL pointing to the generated image. For instance, you might receive an output like this:

https://assets.cognitiveactions.com/invocations/9c017b7f-e988-45b7-895a-2af039d27f24/2e220693-b109-41c0-b3aa-6229eb6ed909.png

Conceptual Usage Example (Python)

Here’s how you can call this action using Python. This conceptual example outlines how to structure the input payload and make the API call.

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 = "a1e3fac9-cbf9-4ebf-a1f6-590c3c5b0d8b"  # Action ID for Generate Image with SDXL Models

# Construct the input payload based on the action's requirements
payload = {
    "width": 1024,
    "height": 1024,
    "prompt": "magical Castel",
    "sampler": "DPMPP_2M",
    "modelName": "cyberrealistic_xl_cyberdelia",
    "layerWeight": 0.8,
    "guidanceScale": 7.5,
    "negativePrompt": "worst quality, low quality, normal quality, lowres, low details...",
    "instructionStrength": 0.8,
    "numberOfInferenceSteps": 30
}

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 snippet, replace the COGNITIVE_ACTIONS_API_KEY and the endpoint URL with your actual values. The payload structure matches the required input schema.

Conclusion

The goodguy1963/good-sdxl-models-plus-loras Cognitive Actions provide a robust solution for developers looking to integrate advanced image generation into their applications. By leveraging these pre-built actions, you can streamline your development process and create stunning visual content with ease. Explore potential use cases such as game design, content creation, or art generation, and elevate your projects using these powerful tools!