Transform Your Images with Inpainting: A Guide to the jerakst/banochka Cognitive Actions

24 Apr 2025
Transform Your Images with Inpainting: A Guide to the jerakst/banochka Cognitive Actions

In today's digital landscape, generating and modifying images has become an essential task for developers across various applications. The jerakst/banochka Cognitive Actions provide a powerful toolset for creating and customizing images using advanced inpainting techniques. By leveraging these pre-built actions, developers can focus on building their applications while gaining access to sophisticated image generation capabilities with minimal effort.

Prerequisites

Before you start using the Cognitive Actions provided by the jerakst/banochka spec, ensure you have the following:

  • An API key for the Cognitive Actions platform. This key will be used to authenticate your requests.
  • Basic knowledge of making API requests, particularly using JSON payloads.

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

Cognitive Actions Overview

Generate Image with Inpainting

Description:
This action generates images using advanced inpainting techniques, allowing for customization of various image properties such as width, height, and aspect ratio. It utilizes optimized models for detailed and rapid image generation, with prompts influencing the style and content of the output.

Category: image-generation

Input

The input schema for this action requires the following fields, with some optional parameters to refine the image generation process:

  • prompt (required): A description of the image you wish to create. For example, "A white elongated jar BANOCHKAMAS stands on the table, a towel lies nearby. 8k, super realistic".
  • model (optional): Choose between "dev" or "schnell". Default is "dev".
  • aspectRatio (optional): Defines the aspect ratio for the image. Options include "1:1", "16:9", and "custom".
  • outputFormat (optional): Specifies the format of the output image, such as "webp", "jpg", or "png".
  • Additional parameters include width, height, guidanceScale, numberOfOutputs, inferenceStepsCount, and more, which can be used to control various aspects of the image generation.

Example Input

Here's an example JSON payload to invoke this action:

{
  "model": "dev",
  "prompt": "A white elongated jar BANOCHKAMAS stands on the table, a towel lies nearby. 8k, super realistic",
  "aspectRatio": "1:1",
  "outputFormat": "webp",
  "guidanceScale": 3,
  "mainLoraScale": 1.01,
  "outputQuality": 80,
  "enableFastMode": false,
  "extraLoraScale": 1,
  "promptStrength": 0.8,
  "numberOfOutputs": 2,
  "inferenceStepsCount": 28,
  "approximatelyMegapixels": "1"
}

Output

The output of this action typically consists of an array of URLs pointing to the generated images. For example:

[
  "https://assets.cognitiveactions.com/invocations/61804e0a-a2c4-4970-922f-52354f2aba86/72ffe3c1-4880-430a-855d-145b895233aa.webp",
  "https://assets.cognitiveactions.com/invocations/61804e0a-a2c4-4970-922f-52354f2aba86/d7c54bee-7006-464f-aa17-606357ce3ff7.webp"
]

Conceptual Usage Example (Python)

Here’s how you might call this 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 = "e6a3c20f-35e2-49bc-97b7-184dd15c795b"  # Action ID for Generate Image with Inpainting

# Construct the input payload based on the action's requirements
payload = {
    "model": "dev",
    "prompt": "A white elongated jar BANOCHKAMAS stands on the table, a towel lies nearby. 8k, super realistic",
    "aspectRatio": "1:1",
    "outputFormat": "webp",
    "guidanceScale": 3,
    "mainLoraScale": 1.01,
    "outputQuality": 80,
    "enableFastMode": False,
    "extraLoraScale": 1,
    "promptStrength": 0.8,
    "numberOfOutputs": 2,
    "inferenceStepsCount": 28,
    "approximatelyMegapixels": "1"
}

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 Image with Inpainting action. The input payload is structured as per the action's requirements, and the response is printed out for review.

Conclusion

The jerakst/banochka Cognitive Actions provide developers with robust capabilities for generating and customizing images efficiently. By understanding how to utilize these actions effectively, you can enhance your applications with advanced image generation features. Consider exploring the various parameters available to tailor the image output to your specific needs, and don't hesitate to experiment with different prompts to unlock creative possibilities!