Create Stunning Images with the stampenlive/insanestamp Cognitive Actions

22 Apr 2025
Create Stunning Images with the stampenlive/insanestamp Cognitive Actions

In today's world of digital creativity, generating unique and compelling images is essential for various applications, from marketing to entertainment. The stampenlive/insanestamp API provides powerful Cognitive Actions for image generation, particularly through its innovative inpainting and image-to-image capabilities. With options for custom masks, aspect ratios, and optimization settings, developers can easily harness these pre-built actions to enhance their applications.

Prerequisites

Before you begin integrating the Cognitive Actions from the stampenlive/insanestamp API, ensure you have the following:

  • An API key for the Cognitive Actions platform, which will be used for authentication.
  • Basic knowledge of JSON format for structuring your requests.

To authenticate, you will typically pass your API key in the headers of your requests, allowing you to securely access the Cognitive Actions.

Cognitive Actions Overview

Generate Image with Inpainting

Description: This action generates an image using inpainting and image-to-image modes, offering options for custom masks, aspect ratios, and optimization settings. You can choose between two models: 'dev' for detailed inference and 'schnell' for faster results.

Category: Image Generation

Input

The input schema requires the following fields:

  • prompt (string, required): The text prompt guiding image generation.
  • mask (string, optional): URI of the image mask for inpainting mode.
  • image (string, optional): URI of the input image for image-to-image or inpainting modes.
  • model (string, optional): Inference model selection ('dev' or 'schnell').
  • width (integer, optional): Width of the generated image, valid only when aspect_ratio is set to custom.
  • height (integer, optional): Height of the generated image, valid only when aspect_ratio is set to custom.
  • outputCount (integer, optional): Number of images to generate (1 to 4).
  • aspectRatio (string, optional): Desired aspect ratio for the generated image.
  • outputFormat (string, optional): File format for the output images ('webp', 'jpg', 'png').
  • guidanceScale (number, optional): Configures the guidance scale during diffusion.
  • denoisingSteps (integer, optional): Number of denoising steps taken.
  • additional parameters: Several other optional fields for fine-tuning image generation.

Example Input:

{
  "model": "dev",
  "prompt": "Create a IMDB profile photo of INSANESTAMP2, a young virtual producer, 22 years old, leading a 3D virtual and AI production company. The individual should exude confidence and dynamism, with a futuristic and modern background. opt for an original outfit, A URBAN STYLED HAT that is stylish yet not overly extravagant, reflecting Gen Z trends. The background should include elements of virtual production, 3D graphics, and AI, showcasing an innovative and cutting-edge environment.",
  "loraScale": 0.67,
  "aspectRatio": "16:9",
  "outputCount": 3,
  "outputFormat": "png",
  "guidanceScale": 3,
  "outputQuality": 100,
  "denoisingSteps": 50,
  "promptStrength": 0.83,
  "additionalLoraStrength": 1
}

Output

The action typically returns an array of image URLs corresponding to the generated images.

Example Output:

[
  "https://assets.cognitiveactions.com/invocations/bfc31e4e-1e36-4b4d-9616-6a04f79bf582/357e5813-5d8c-4446-b8e6-34af166886db.png",
  "https://assets.cognitiveactions.com/invocations/bfc31e4e-1e36-4b4d-9616-6a04f79bf582/cb192d85-4244-40bf-a32d-1e3d0e939cbb.png",
  "https://assets.cognitiveactions.com/invocations/bfc31e4e-1e36-4b4d-9616-6a04f79bf582/e2993007-ed95-4ce6-932f-d9e7ba66a603.png"
]

Conceptual Usage Example (Python)

Here’s a conceptual Python code snippet to demonstrate how you might call this 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 = "9370e578-fcf8-4cde-bd2c-9588fa111d3a" # Action ID for Generate Image with Inpainting

# Construct the input payload based on the action's requirements
payload = {
    "model": "dev",
    "prompt": "Create a IMDB profile photo of INSANESTAMP2, a young virtual producer, 22 years old, leading a 3D virtual and AI production company. The individual should exude confidence and dynamism, with a futuristic and modern background. opt for an original outfit, A URBAN STYLED HAT that is stylish yet not overly extravagant, reflecting Gen Z trends. The background should include elements of virtual production, 3D graphics, and AI, showcasing an innovative and cutting-edge environment.",
    "loraScale": 0.67,
    "aspectRatio": "16:9",
    "outputCount": 3,
    "outputFormat": "png",
    "guidanceScale": 3,
    "outputQuality": 100,
    "denoisingSteps": 50,
    "promptStrength": 0.83,
    "additionalLoraStrength": 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, replace the YOUR_COGNITIVE_ACTIONS_API_KEY with your actual API key and ensure the endpoint URL is set correctly. The action_id corresponds to the Generate Image with Inpainting action. The payload constructs the input JSON based on the required schema.

Conclusion

The stampenlive/insanestamp Cognitive Actions provide an easy and efficient way for developers to create stunning images tailored to specific prompts. By leveraging the power of inpainting and customizable settings, you can integrate advanced image generation capabilities into your applications. Explore these actions further and consider how they can enhance your projects, whether for artistic purposes, marketing, or user engagement. Happy coding!