Create Stunning Images with the doriandarko/lcm-hiroshinagai Cognitive Actions

22 Apr 2025
Create Stunning Images with the doriandarko/lcm-hiroshinagai Cognitive Actions

In today's digital landscape, the ability to generate unique images programmatically opens up exciting possibilities for developers. The doriandarko/lcm-hiroshinagai spec offers a powerful tool for creating images through the SDXL Hiroshi Nagai model. This model is designed to produce smaller and cuter outputs, providing flexibility with customizable settings for various image generation modes including img2img and inpainting. By leveraging these Cognitive Actions, developers can enhance their applications with creative visual content while saving time.

Prerequisites

Before diving into the integration of Cognitive Actions, you will need:

  • An API key for the Cognitive Actions platform to authenticate your requests.
  • A basic understanding of how to structure JSON payloads for API calls.

Authentication typically involves passing your API key in the request headers, allowing the system to verify your identity and authorize your access to the actions.

Cognitive Actions Overview

Generate Image with SDXL Hiroshi Nagai Model

This action allows you to create images using the SDXL Hiroshi Nagai model. It supports various modes and customizable settings to suit your creative needs.

Input

The input for this action follows the CompositeRequest schema, which includes the following fields:

  • mask (optional): URI for the input mask in inpaint mode.
  • seed (optional): Random seed value for image generation.
  • image (optional): URI for the input image used in img2img or inpaint modes.
  • width (optional): The width in pixels of the output image. Default is 1024.
  • height (optional): The height in pixels of the output image. Default is 1024.
  • prompt (required): Main input prompt describing the desired output.
  • loraScale (optional): Scale for the LoRA additive. Default is 0.6.
  • scheduler (optional): Algorithm used for scheduling diffusion steps. Default is 'LCM'.
  • guidanceScale (optional): Scale factor for classifier-free guidance. Default is 2.
  • applyWatermark (optional): Applies a watermark to the image. Default is true.
  • negativePrompt (optional): Excludes certain elements from the generated image.
  • promptStrength (optional): Strength of the prompt application. Default is 0.8.
  • numberOfOutputs (optional): Total number of images to generate (1 to 4). Default is 1.
  • numberOfInferenceSteps (optional): Specifies the number of denoising steps. Default is 6.

Example Input:

{
  "seed": 1989,
  "width": 1024,
  "height": 1024,
  "prompt": "In the style of TOK, a car in the countryside",
  "loraScale": 0.6,
  "scheduler": "LCM",
  "guidanceScale": 2,
  "applyWatermark": true,
  "negativePrompt": "black and white, ugly, ",
  "promptStrength": 0.8,
  "numberOfOutputs": 4,
  "numberOfInferenceSteps": 6
}

Output

The action returns an array of URLs pointing to the generated images. Each URL links to a different output image based on the specified parameters.

Example Output:

[
  "https://assets.cognitiveactions.com/invocations/7227b24a-06df-4660-9c8c-f3f507735f0f/75523d27-1485-46c9-be43-04d57148c5e5.png",
  "https://assets.cognitiveactions.com/invocations/7227b24a-06df-4660-9c8c-f3f507735f0f/81ee4e77-750e-4717-851f-288b1207c3f9.png",
  "https://assets.cognitiveactions.com/invocations/7227b24a-06df-4660-9c8c-f3f507735f0f/27e14bf7-9cc8-456d-ba6e-546b837810d2.png",
  "https://assets.cognitiveactions.com/invocations/7227b24a-06df-4660-9c8c-f3f507735f0f/2a3866ce-ac2c-4c93-b925-010eef242eb6.png"
]

Conceptual Usage Example (Python)

Here’s how you might invoke the Generate Image with SDXL Hiroshi Nagai Model 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 = "de336a5b-b451-4c7c-8433-5ba19f44d571" # Action ID for Generate Image with SDXL Hiroshi Nagai Model

# Construct the input payload based on the action's requirements
payload = {
    "seed": 1989,
    "width": 1024,
    "height": 1024,
    "prompt": "In the style of TOK, a car in the countryside",
    "loraScale": 0.6,
    "scheduler": "LCM",
    "guidanceScale": 2,
    "applyWatermark": True,
    "negativePrompt": "black and white, ugly, ",
    "promptStrength": 0.8,
    "numberOfOutputs": 4,
    "numberOfInferenceSteps": 6
}

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 YOUR_COGNITIVE_ACTIONS_API_KEY with your actual API key. The action ID and input payload are structured according to the specifications of the Cognitive Action.

Conclusion

The doriandarko/lcm-hiroshinagai Cognitive Actions provide a robust and flexible way to generate images that can enrich your applications. By using the Generate Image with SDXL Hiroshi Nagai Model, you can easily create stunning visuals tailored to your specific prompts and preferences. Start experimenting with these actions today and unlock your creative potential!