Create Stunning Images with mavrickgallery/shiny Cognitive Actions

22 Apr 2025
Create Stunning Images with mavrickgallery/shiny Cognitive Actions

The mavrickgallery/shiny API provides developers with powerful Cognitive Actions designed for image generation and manipulation. These pre-built actions enable you to create detailed images efficiently, whether you’re looking to enhance existing visuals or generate new artwork from descriptive prompts. By leveraging these capabilities, developers can integrate sophisticated image processing features into their applications, enhancing user experience and creative possibilities.

Prerequisites

Before you start using the Cognitive Actions from the mavrickgallery/shiny API, ensure you have the following in place:

  • An API key for the Cognitive Actions platform.
  • Basic understanding of how to make HTTP requests in your programming language of choice, as you will be interacting with a RESTful API.

Authentication is typically achieved by including your API key in the headers of your requests. This allows you to securely access the Cognitive Actions.

Cognitive Actions Overview

Generate Image with Mask Inpainting

Description:
This action generates detailed images using either image-to-image or inpainting modes. It offers speed optimization and control over output parameters, like image quality and LoRA intensity. You can choose from different models, including 'dev' for high detail and 'schnell' for quick production.

Category: image-generation

Input

The input schema for this action requires several fields, with the prompt being mandatory. Here’s the breakdown:

  • prompt (required): A descriptive text prompt for the image generation.
  • mask: Image mask for inpainting mode (optional).
  • image: Input image for image transformation (optional).
  • width: Desired width of the generated image (optional).
  • height: Desired height of the generated image (optional).
  • goFast: Enables a model optimized for speed (default: false).
  • loraScale: Scale for LoRA application (default: 1).
  • modelType: Choose between 'dev' or 'schnell' (default: 'dev').
  • guidanceScale: Sets the guidance scale for image quality (default: 3).
  • outputQuality: Quality of output images (default: 80).
  • numberOfOutputs: Number of images to generate (default: 1).
  • imageAspectRatio: Aspect ratio for the image (default: '1:1').
  • imageOutputFormat: Format of the output image (default: 'webp').

Example Input:

{
  "goFast": false,
  "prompt": "Shynu, likely in her late teens or early twenties, with a light complexion and dark hair styled in a loose bun, stands in a serene shallow body of water...",
  "loraScale": 1.04,
  "modelType": "dev",
  "guidanceScale": 3,
  "outputQuality": 80,
  "numberOfOutputs": 1,
  "imageAspectRatio": "1:1",
  "imageOutputFormat": "jpg"
}

Output

The output of this action consists of URLs pointing to the generated image files. Here’s an example of what you can expect:

Example Output:

[
  "https://assets.cognitiveactions.com/invocations/5c985b75-f0a5-4fe6-839f-15ec0a1b10b2/d188d2c5-d5b4-49d2-92c0-e583b247d5c2.jpg"
]

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 = "681bf6b7-9040-4949-91c4-90bc674f0423"  # Action ID for Generate Image with Mask Inpainting

# Construct the input payload based on the action's requirements
payload = {
    "goFast": False,
    "prompt": "Shynu, likely in her late teens or early twenties, with a light complexion and dark hair styled in a loose bun...",
    "loraScale": 1.04,
    "modelType": "dev",
    "guidanceScale": 3,
    "outputQuality": 80,
    "numberOfOutputs": 1,
    "imageAspectRatio": "1:1",
    "imageOutputFormat": "jpg"
}

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 Python code snippet, replace "YOUR_COGNITIVE_ACTIONS_API_KEY" with your actual API key. The payload is structured according to the input schema specified earlier, while the action_id corresponds to the Generate Image with Mask Inpainting action.

Conclusion

The mavrickgallery/shiny Cognitive Actions provide a powerful way to integrate advanced image generation capabilities into your applications. By utilizing the Generate Image with Mask Inpainting action, you can create stunning visuals tailored to your specifications. Explore the diverse possibilities of this API to enhance your projects, whether for creative expression or practical applications. Start experimenting with these actions today!