Create Stunning Images with jbilcke/sdxl-lean-moebius Cognitive Actions

22 Apr 2025
Create Stunning Images with jbilcke/sdxl-lean-moebius Cognitive Actions

In today's digital landscape, the ability to generate high-quality images from text prompts has become an essential capability for developers aiming to enhance their applications. The jbilcke/sdxl-lean-moebius API provides a powerful Cognitive Action designed to create images using various refinement methods. This action supports advanced features like img2img and inpainting modes, allowing for detailed customizations such as dimensions, refinement steps, and prompt guidance. By leveraging these pre-built actions, developers can streamline their workflow and focus on creating exceptional user experiences.

Prerequisites

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

  • An API key for the jbilcke/sdxl-lean-moebius service. This key will be used to authenticate your requests.
  • Familiarity with JSON and HTTP requests, as you will be constructing JSON payloads for the API calls.

Conceptually, authentication typically involves passing the API key in the request headers.

Cognitive Actions Overview

Generate Image with Refinement

The Generate Image with Refinement action allows you to create high-quality images from text prompts and offers various customization options. With support for inpainting and img2img, this action is versatile for generating images that meet specific design needs.

  • Category: Image Generation
  • Purpose: To create images based on textual prompts with options for refinement.

Input

The action accepts a comprehensive input schema. Below are the required and optional fields:

  • prompt (string, required): The guiding text for image creation. Default: "An astronaut riding a rainbow unicorn".
  • width (integer, optional): The output image width. Default: 1024.
  • height (integer, optional): The output image height. Default: 1024.
  • guidanceScale (number, optional): Scale factor for guidance. Range: 1 to 50. Default: 7.5.
  • promptStrength (number, optional): Strength of the prompt (0 to 1). Default: 0.8.
  • numberOfOutputs (integer, optional): Number of images to generate (1 to 4). Default: 1.
  • refinementStyle (string, optional): The refinement method (options: "no_refiner", "expert_ensemble_refiner", or "base_image_refiner"). Default: "no_refiner".
  • includeWatermark (boolean, optional): Whether to apply a watermark. Default: true.
  • schedulingMethod (string, optional): The scheduling algorithm for generation. Default: "K_EULER".
  • highNoiseFraction (number, optional): Fraction of noise for refinements (0 to 1). Default: 0.8.
  • inferenceStepCount (integer, optional): Number of denoising steps (1 to 500). Default: 50.
  • loraAdjustmentScale (number, optional): Additive scale for LoRA adjustments (0 to 1). Default: 0.6.

Example Input:

{
  "width": 1024,
  "height": 1024,
  "prompt": "intricate details, beautiful, spaceship flying over canyon, in the style of TOK",
  "guidanceScale": 18.14,
  "promptStrength": 0.8,
  "numberOfOutputs": 1,
  "refinementStyle": "no_refiner",
  "includeWatermark": true,
  "schedulingMethod": "K_EULER",
  "highNoiseFraction": 0.8,
  "inferenceStepCount": 50,
  "loraAdjustmentScale": 0.83
}

Output

Upon successful completion, this action typically returns an array of image URLs generated based on the provided prompt and settings.

Example Output:

[
  "https://assets.cognitiveactions.com/invocations/5f29038f-815d-4a04-8954-0e0a32f1cabf/65138b0b-2a0e-4a82-adbc-55d442338cd5.png"
]

Conceptual Usage Example (Python)

Here’s how you might structure a Python script to execute the Generate Image with Refinement 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 = "9a2268d9-b9f6-4c7d-bc4a-dcbb48837a60"  # Action ID for Generate Image with Refinement

# Construct the input payload based on the action's requirements
payload = {
    "width": 1024,
    "height": 1024,
    "prompt": "intricate details, beautiful, spaceship flying over canyon, in the style of TOK",
    "guidanceScale": 18.14,
    "promptStrength": 0.8,
    "numberOfOutputs": 1,
    "refinementStyle": "no_refiner",
    "includeWatermark": True,
    "schedulingMethod": "K_EULER",
    "highNoiseFraction": 0.8,
    "inferenceStepCount": 50,
    "loraAdjustmentScale": 0.83
}

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, replace YOUR_COGNITIVE_ACTIONS_API_KEY with your actual API key. The action ID corresponds to the Generate Image with Refinement action, and the payload is structured based on the required input schema.

Conclusion

The jbilcke/sdxl-lean-moebius Cognitive Action for generating images with refinement offers developers an efficient way to create unique visuals tailored to specific needs. By utilizing the various options available, you can enhance the quality and relevance of the images produced. Whether for artistic endeavors, app development, or marketing campaigns, these capabilities can significantly elevate your output. Start experimenting with different prompts and settings to unlock the full potential of this powerful image generation tool!