Generate Stunning Images with Inpainting Using microphonist/retro_one Actions

24 Apr 2025
Generate Stunning Images with Inpainting Using microphonist/retro_one Actions

In the world of digital content creation, the ability to generate high-quality images programmatically can be a game changer. The microphonist/retro_one API offers powerful Cognitive Actions that enable developers to create images through innovative methods such as inpainting, providing flexibility in image generation with configurable settings. These pre-built actions streamline the process of integrating image generation capabilities into your applications, allowing you to focus more on creativity and less on the underlying complexity.

Prerequisites

To get started with the microphonist/retro_one Cognitive Actions, you'll need the following:

  • API Key: Ensure you have an API key from the Cognitive Actions platform, which will be used for authentication.
  • HTTP Client: You will need an HTTP client to make requests to the API (e.g., requests in Python).

Authentication typically involves including the API key in the request headers when making API calls.

Cognitive Actions Overview

Generate Image with Inpainting

The Generate Image with Inpainting action allows you to create images using advanced techniques, including inpainting capabilities that support various resolutions and output formats. You can enhance your generated images with features like LoRA intensity manipulation and fast generation mode, making it versatile for different use cases.

Input

The input schema for this action requires the following fields:

  • prompt (required): Text prompt for image generation. For example:
    "prompt": "rtro1a handsome young sophisticated man with brown short hair in a neon sweater holding a robot furry cat close to his face. he is in a small studio apartment."
    
  • model: Specifies the inference model to use. Options include "dev" (default) and "schnell".
  • numberOfOutputs: Specifies how many images to generate (minimum of 1, maximum of 4).
  • imageAspectRatio: Defines the aspect ratio for the output image.
  • outputMegapixels: Approximate megapixels for the images.
  • imageOutputFormat: Select from available formats such as "webp", "jpg", and "png".
  • denoisingStepCount: Number of denoising steps; higher values enhance detail.
  • imageOutputQuality: Quality of the output image ranging from 0 to 100.

Here is an example input JSON payload:

{
  "model": "dev",
  "prompt": "rtro1a handsome young sophisticated man with brown short hair in a neon sweater holding a robot furry cat close to his face. he is in a small studio apartment.",
  "enableFastMode": false,
  "numberOfOutputs": 2,
  "imageAspectRatio": "16:9",
  "outputMegapixels": "1",
  "imageOutputFormat": "webp",
  "denoisingStepCount": 36,
  "imageOutputQuality": 94,
  "imagePromptStrength": 0.71,
  "diffusionGuidanceScale": 8.25,
  "additionalLoraIntensity": 1,
  "loraApplicationIntensity": 1.33
}

Output

Upon successful execution, the action returns an array of image URLs. For example:

[
  "https://assets.cognitiveactions.com/invocations/a1368ae2-f2e5-430b-b5f7-d780aa8f0bc3/f28e333b-c086-476c-90a9-6f5bec718ca1.webp",
  "https://assets.cognitiveactions.com/invocations/a1368ae2-f2e5-430b-b5f7-d780aa8f0bc3/e50cd72f-813e-4cdd-824f-a7233e103f23.webp"
]

If there are any issues with the request, the output may contain error details.

Conceptual Usage Example (Python)

Here’s a conceptual Python code 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 = "c3f11eef-7f66-40bf-852b-95443ecd06f6"  # Action ID for Generate Image with Inpainting

# Construct the input payload based on the action's requirements
payload = {
    "model": "dev",
    "prompt": "rtro1a handsome young sophisticated man with brown short hair in a neon sweater holding a robot furry cat close to his face. he is in a small studio apartment.",
    "enableFastMode": False,
    "numberOfOutputs": 2,
    "imageAspectRatio": "16:9",
    "outputMegapixels": "1",
    "imageOutputFormat": "webp",
    "denoisingStepCount": 36,
    "imageOutputQuality": 94,
    "imagePromptStrength": 0.71,
    "diffusionGuidanceScale": 8.25,
    "additionalLoraIntensity": 1,
    "loraApplicationIntensity": 1.33
}

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 example, replace YOUR_COGNITIVE_ACTIONS_API_KEY with your actual API key. The action ID for Generate Image with Inpainting is specified, and the input payload is structured according to the action's requirements.

Conclusion

The microphonist/retro_one Cognitive Actions provide developers with powerful tools for generating images with inpainting capabilities. By leveraging these actions, you can enhance your applications with dynamic image generation features that cater to various creative needs. Start experimenting with the provided action and unleash your creativity!