Generate Stunning Minecraft Images with Cognitive Actions for Image Generation

22 Apr 2025
Generate Stunning Minecraft Images with Cognitive Actions for Image Generation

Introduction

In the realm of creative applications and game development, visual content plays a crucial role in user engagement. The ori299/mc-thumbnails-v1 API offers a powerful Cognitive Action that allows developers to generate custom Minecraft-themed images using text prompts and image inpainting. This action leverages optimized models to cater to different inference needs, enabling fast generation and customizable parameters such as aspect ratio and output quality. By integrating this action into your applications, you can enhance user experience, create engaging visuals, and automate the content creation process.

Prerequisites

Before you start using the Cognitive Actions, ensure you have the following:

  • An API key for the Cognitive Actions platform.
  • Basic knowledge of making HTTP requests.
  • Familiarity with JSON format for constructing input payloads.

Authentication typically involves passing your API key in the request headers, allowing you to securely access the API's functionalities.

Cognitive Actions Overview

Generate Minecraft Image

The Generate Minecraft Image action allows users to create unique Minecraft-themed images based on a detailed text prompt. The operation supports image inpainting for customization and utilizes various models optimized for different requirements, including speed and output quality.

Input

To invoke this action, you must construct a JSON payload according to the following schema:

  • prompt (required): A detailed text prompt that describes the desired image.
  • mask (optional): An image mask for inpainting mode, ignoring width and height inputs if provided.
  • seed (optional): An integer seed for reproducible generation.
  • image (optional): An input image for image-to-image or inpainting mode, which also ignores width and height inputs if included.
  • model (optional): Specifies the inference model version; defaults to "dev".
  • width (optional): Specifies the width of the generated image (only applies if aspect_ratio is set to "custom").
  • height (optional): Specifies the height of the generated image (only applies if aspect_ratio is set to "custom").
  • totalOutputs (optional): Defines the number of images to generate (1 to 4).
  • loraIntensity (optional): Determines the strength of the main LoRA application (default: 1).
  • outputQuality (optional): Sets the quality level for output images (0 to 100).
  • imageAspectRatio (optional): Specifies the aspect ratio of the generated image.
  • imageOutputFormat (optional): Sets the format for output images (webp, jpg, png).
  • imageGuidanceScale (optional): Controls the guidance scale during the diffusion process.
  • inferenceStepsCount (optional): Specifies the number of denoising steps during inference.

Here’s an example of a JSON payload for this action:

{
  "model": "dev",
  "prompt": "Create a TOK featuring a Minecraft village scene. On the left side of the canvas, depict a charming, well-maintained village with cobblestone paths, neat wooden houses with thatched roofs, and villagers engaging in daily activities like farming and trading. The village is surrounded by lush greenery, including a small garden with crops and a few animals like cows and pigs. The sky is clear with a bright sun, and the overall atmosphere is peaceful and welcoming.\n\nOn the right side, illustrate a rugged, mountainous terrain. Show a mining area with exposed stone and ores, and a few miners in protective gear working with pickaxes and shovels. Add details like mining carts and a makeshift shelter with torches for light. The landscape should be rough and uneven, with steep cliffs and sparse vegetation. The sky is overcast with some dark clouds, reflecting the challenging environment of mining.\n\nThe background should clearly emphasize the contrast between the peaceful, organized village and the rugged, industrious mining area, showcasing the different aspects of Minecraft life.",
  "totalOutputs": 2,
  "loraIntensity": 1,
  "outputQuality": 80,
  "imageAspectRatio": "16:9",
  "imageOutputFormat": "png",
  "imageGuidanceScale": 3.5,
  "inferenceStepsCount": 50,
  "additionalLoraIntensity": 0.8
}

Output

Upon successful execution, the action will return an array of URLs pointing to the generated images. For instance:

[
  "https://assets.cognitiveactions.com/invocations/d3a7af97-fdd8-45fb-8066-180a7f62e96b/9b116c11-4d94-43db-9e90-65d20a8071bc.png",
  "https://assets.cognitiveactions.com/invocations/d3a7af97-fdd8-45fb-8066-180a7f62e96b/62e7bb15-0381-4676-92ff-fe4fed07d1f5.png"
]

Conceptual Usage Example (Python)

Here’s a conceptual Python code snippet demonstrating how to call the Generate Minecraft Image 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 = "4d53118c-1086-4071-8b13-87b8d7bc0b6c"  # Action ID for Generate Minecraft Image

# Construct the input payload based on the action's requirements
payload = {
    "model": "dev",
    "prompt": "Create a TOK featuring a Minecraft village scene...",
    "totalOutputs": 2,
    "loraIntensity": 1,
    "outputQuality": 80,
    "imageAspectRatio": "16:9",
    "imageOutputFormat": "png",
    "imageGuidanceScale": 3.5,
    "inferenceStepsCount": 50,
    "additionalLoraIntensity": 0.8
}

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 corresponds to the Generate Minecraft Image action. The input payload is structured according to the action's requirements, and the response is handled to display the generated image URLs.

Conclusion

The Generate Minecraft Image Cognitive Action opens up creative possibilities for developers looking to incorporate Minecraft-themed visuals into their applications. By leveraging this action, you can streamline the image generation process and deliver engaging content to your users. Whether you're developing a game, a creative tool, or an educational platform, this API provides the means to enhance your visual storytelling. Start experimenting with different prompts and parameters to unleash your creativity!