Generate Stunning Images Using the lucataco/blueprint Cognitive Actions

22 Apr 2025
Generate Stunning Images Using the lucataco/blueprint Cognitive Actions

In this blog post, we'll explore the powerful capabilities of the lucataco/blueprint API, specifically focusing on the Generate Blueprint-Focused Image with SDXL action. This action allows developers to harness advanced image generation techniques using a fine-tuned SDXL model tailored for blueprint designs. With a variety of customization options and refinement styles, you can create stunning images that meet your specific requirements with ease.

Prerequisites

Before you begin integrating the Cognitive Actions into your application, ensure you have the following:

  • An API key for the Cognitive Actions platform.
  • Basic understanding of making HTTP requests and handling JSON data.

Conceptually, authentication typically involves passing your API key in the request headers, which we'll demonstrate in the examples below.

Cognitive Actions Overview

Generate Blueprint-Focused Image with SDXL

The Generate Blueprint-Focused Image with SDXL action is designed to generate images based on blueprint designs. It provides robust customization options and multiple refinement styles, making it ideal for developers looking to create unique and tailored visual content.

Input

The action requires a JSON payload structured according to the following schema:

{
  "mask": "string (uri)",
  "seed": "integer",
  "image": "string (uri)",
  "width": 1024,
  "height": 1024,
  "prompt": "A TOK blueprint of a museum",
  "refine": "no_refiner",
  "scheduler": "K_EULER",
  "loraWeights": "string",
  "refineSteps": "integer",
  "guidanceScale": 7.5,
  "applyWatermark": true,
  "negativePrompt": "string",
  "promptStrength": 0.8,
  "numberOfOutputs": 1,
  "highNoiseFraction": 0.8,
  "loraAdditiveScale": 0.6,
  "disableSafetyChecker": false,
  "numberOfInferenceSteps": 50
}

Example Input:

{
  "width": 1024,
  "height": 1024,
  "prompt": "A TOK blueprint of a museum",
  "refine": "no_refiner",
  "scheduler": "K_EULER",
  "guidanceScale": 7.5,
  "applyWatermark": true,
  "promptStrength": 0.8,
  "numberOfOutputs": 1,
  "highNoiseFraction": 0.8,
  "loraAdditiveScale": 0.6,
  "numberOfInferenceSteps": 50
}

Output

Upon successful execution, the action returns an array of generated image URLs. Here's an example of the output you might receive:

[
  "https://assets.cognitiveactions.com/invocations/9cb8d7f7-f796-486d-8777-9885f5b9a3ca/dcc12430-20f2-4db7-992f-8f8f711abc00.png"
]

Conceptual Usage Example (Python)

Here's a conceptual example of how you might call the Cognitive Actions execution endpoint to generate a blueprint-focused image:

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 = "8e7161ee-1470-4b08-9da8-2b2b056f2a4d"  # Action ID for Generate Blueprint-Focused Image with SDXL

# Construct the input payload based on the action's requirements
payload = {
    "width": 1024,
    "height": 1024,
    "prompt": "A TOK blueprint of a museum",
    "refine": "no_refiner",
    "scheduler": "K_EULER",
    "guidanceScale": 7.5,
    "applyWatermark": True,
    "promptStrength": 0.8,
    "numberOfOutputs": 1,
    "highNoiseFraction": 0.8,
    "loraAdditiveScale": 0.6,
    "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 code snippet, we set up a request to the Cognitive Actions API, specifying the necessary headers and input payload. Notice how we include the action ID and construct the JSON payload according to the input schema. The endpoint URL is illustrative, so be sure to replace it with the actual URL provided by your Cognitive Actions platform.

Conclusion

The Generate Blueprint-Focused Image with SDXL action from the lucataco/blueprint API offers developers a robust solution for creating unique images based on their specifications. With its flexible input options and powerful customization capabilities, you can easily generate images that align with your project needs.

Next steps may include exploring additional actions available within the lucataco/blueprint API, or implementing this action in a larger application to automate image generation workflows. Happy coding!