Unleashing Creativity: Integrate Image Inpainting with nazacyn/gjennevva Cognitive Actions

24 Apr 2025
Unleashing Creativity: Integrate Image Inpainting with nazacyn/gjennevva Cognitive Actions

In today's digital landscape, crafting stunning visuals is more critical than ever. The nazacyn/gjennevva API provides powerful Cognitive Actions designed to enhance your image generation capabilities. Among these, the Generate Inpainting Image Using Composite Request action stands out as an innovative solution, enabling developers to create high-quality images through advanced inpainting techniques. This action allows users to customize various parameters, ensuring that the output meets specific needs, whether for artistic projects, marketing materials, or content creation.

Prerequisites

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

  • API Key: You will need an API key to authenticate your requests to the Cognitive Actions platform. This key should be passed in the request headers.
  • Internet Access: As the API processes requests over the web, ensure your application can make HTTP requests.

Authentication Concept

Authentication typically involves including your API key in the request headers as follows:

Authorization: Bearer YOUR_COGNITIVE_ACTIONS_API_KEY

Cognitive Actions Overview

Generate Inpainting Image Using Composite Request

This action leverages advanced inpainting techniques to generate high-quality images using a customizable mask, width, height, and various model configurations. It supports fast and detailed batch image processing, allowing users to control the output format, quality, and guidance scale for more realistic imaging.

Input

The input for this action is structured as a JSON object that includes the following fields:

  • prompt (required): The textual description for the image to be generated.
  • mask (optional): URI of an image mask used in inpainting mode.
  • seed (optional): A number for reproducible image generation.
  • image (optional): URI of an input image for image-to-image or inpainting mode.
  • width (optional): Width of the generated image (in pixels), effective if aspect_ratio is set to custom.
  • goFast (optional): Optimized for speed, enables fast predictions.
  • height (optional): Height of the generated image (in pixels).
  • aspectRatio (optional): The aspect ratio of the image.
  • numOutputs (optional): Number of images to generate (1 to 4).
  • outputFormat (optional): The file format of the generated images (webp, jpg, png).
  • guidanceScale (optional): Sets the guidance scale for the diffusion process.
  • outputQuality (optional): Quality of the output image.
  • Additional parameters related to model weights, LoRA, and inference settings.

Example Input:

{
  "prompt": "A brightly lit, tastefully designed living room with modern decor. A young woman, GJENNEVVA, with shoulder-length, voluminous hair sits comfortably on a stylish sofa, smiling warmly and looking directly at the camera. She radiates confidence and charm in a cozy yet elegant setting. The room features decorative cushions, a coffee table, and accents like houseplants or artwork, all bathed in soft natural light. The image is captured with a high-quality camera, highlighting sharp details, a vibrant color palette, and a welcoming atmosphere",
  "loraScale": 1,
  "numOutputs": 2,
  "aspectRatio": "16:9",
  "outputFormat": "jpg",
  "guidanceScale": 2.5,
  "outputQuality": 90,
  "extraLoraScale": 1,
  "inferenceModel": "dev",
  "promptStrength": 0.8,
  "numInferenceSteps": 40
}

Output

The action returns an array of image URLs based on the generated images. For example:

[
  "https://assets.cognitiveactions.com/invocations/29fac9e6-81be-4ccf-bac2-be7db7f3e5dd/945992b3-e6e1-431a-bcd2-6ded38385939.jpg",
  "https://assets.cognitiveactions.com/invocations/29fac9e6-81be-4ccf-bac2-be7db7f3e5dd/6b41c7ee-12d1-4d80-a95b-3f10d6a58c88.jpg"
]

Conceptual Usage Example (Python)

Here’s a conceptual Python code snippet illustrating how to call the Generate Inpainting Image 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 = "edf7537b-1e03-46fb-8692-4e00d9d09595"  # Action ID for Generate Inpainting Image

# Construct the input payload based on the action's requirements
payload = {
    "prompt": "A brightly lit, tastefully designed living room with modern decor. A young woman, GJENNEVVA, with shoulder-length, voluminous hair sits comfortably on a stylish sofa, smiling warmly and looking directly at the camera. She radiates confidence and charm in a cozy yet elegant setting. The room features decorative cushions, a coffee table, and accents like houseplants or artwork, all bathed in soft natural light. The image is captured with a high-quality camera, highlighting sharp details, a vibrant color palette, and a welcoming atmosphere",
    "loraScale": 1,
    "numOutputs": 2,
    "aspectRatio": "16:9",
    "outputFormat": "jpg",
    "guidanceScale": 2.5,
    "outputQuality": 90,
    "extraLoraScale": 1,
    "inferenceModel": "dev",
    "promptStrength": 0.8,
    "numInferenceSteps": 40
}

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 and adjust the endpoint URL as necessary. The input JSON payload is structured according to the action's requirements, showcasing how to generate images effectively.

Conclusion

The Generate Inpainting Image Using Composite Request action from the nazacyn/gjennevva API empowers developers to create visually stunning images with ease. With customizable parameters and advanced techniques, this action can be seamlessly integrated into various applications, from art generation to product design. Explore the capabilities of Cognitive Actions and enhance your projects with visually compelling content today!