Transform Your Images with the plugilode/plugilocards Cognitive Actions

24 Apr 2025
Transform Your Images with the plugilode/plugilocards Cognitive Actions

In the world of image generation, the plugilode/plugilocards API offers powerful Cognitive Actions designed to empower developers with advanced image manipulation capabilities. Among these, the Generate Image with Inpainting action stands out, allowing users to create custom images tailored to their specific requirements. By leveraging pre-built actions, developers can streamline their workflow, save time, and focus on enhancing their applications.

Prerequisites

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

  • An API key for accessing the plugilode/plugilocards service.
  • Basic knowledge of making HTTP requests and handling JSON data.
  • A development environment set up to make HTTP requests (e.g., Python with the requests library).

Authentication typically involves passing your API key in the request headers as a Bearer token.

Cognitive Actions Overview

Generate Image with Inpainting

The Generate Image with Inpainting action is designed to create images through either inpainting or image-to-image generation. This action provides flexibility in aspect ratios, allowing for custom dimensions and utilizing different models for varied speeds and fidelity.

  • Category: Image Generation

Input

The input schema for this action requires the following fields:

  • prompt: (string, required) A text prompt to direct the image generation (e.g., "Plugilocards key hole").
  • mask: (string, optional) URI of an image mask for inpainting.
  • seed: (integer, optional) Seed for randomization, ensuring reproducibility.
  • image: (string, optional) URI of the input image for image-to-image generation.
  • width: (integer, optional) Width of the generated image (must be between 256 and 1440).
  • height: (integer, optional) Height of the generated image (must be between 256 and 1440).
  • goFast: (boolean, optional) Enable faster predictions; defaults to false.
  • numOutputs: (integer, optional) Total number of images to generate (minimum 1, maximum 4).
  • guidanceScale: (number, optional) Scale for the diffusion process guidance (recommended range: 2 to 3.5).
  • outputQuality: (integer, optional) Quality of output images (0 to 100).
  • imageOutputFormat: (string, optional) Format for the generated output images (options: webp, jpg, png).
  • Additional parameters for advanced users include extraLora, loraScale, and customWeights.

Here’s an example input JSON payload:

{
  "goFast": false,
  "prompt": "Plugilocards key hole",
  "loraScale": 1,
  "modelType": "dev",
  "numOutputs": 1,
  "guidanceScale": 3,
  "outputQuality": 80,
  "extraLoraScale": 1,
  "promptStrength": 0.8,
  "totalMegapixels": "1",
  "imageAspectRatio": "1:1",
  "imageOutputFormat": "webp",
  "numInferenceSteps": 28
}

Output

On successful execution, this action returns an array of generated image URLs. Here’s an example of a potential output:

[
  "https://assets.cognitiveactions.com/invocations/2e42e0af-004e-4c29-9f51-c823f400117c/6846e450-4028-4e1c-9380-d344b9cd4a50.webp"
]

Conceptual Usage Example (Python)

Below is a conceptual Python snippet demonstrating how to invoke the Generate Image with Inpainting 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 = "58a10666-b902-46f5-a162-20b5f2c985de"  # Action ID for Generate Image with Inpainting

# Construct the input payload based on the action's requirements
payload = {
    "goFast": false,
    "prompt": "Plugilocards key hole",
    "loraScale": 1,
    "modelType": "dev",
    "numOutputs": 1,
    "guidanceScale": 3,
    "outputQuality": 80,
    "extraLoraScale": 1,
    "promptStrength": 0.8,
    "totalMegapixels": "1",
    "imageAspectRatio": "1:1",
    "imageOutputFormat": "webp",
    "numInferenceSteps": 28
}

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 snippet, replace YOUR_COGNITIVE_ACTIONS_API_KEY with your actual API key. The payload structure is customized to fit the action's requirements, ensuring proper execution.

Conclusion

The plugilode/plugilocards Cognitive Actions provide developers with powerful tools to enhance their applications through advanced image generation capabilities. By utilizing the Generate Image with Inpainting action, you can create tailored images that meet your application’s needs. Explore the potential of these actions and consider how they can elevate your projects to the next level!