Generate Stunning Images with the desrucprince/neocortez Cognitive Actions

22 Apr 2025
Generate Stunning Images with the desrucprince/neocortez Cognitive Actions

In the world of digital content creation, the ability to generate customized images on demand can significantly enhance applications across various domains, from gaming to marketing. The desrucprince/neocortez API offers a powerful Cognitive Action designed to enable developers to create visually striking images through advanced inpainting techniques. This action allows users to specify various parameters such as aspect ratios, resolutions, and styles via text prompts, making it an essential tool for applications requiring high-quality visual outputs.

Prerequisites

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

  • An API key for the Cognitive Actions platform to authenticate your requests.
  • Familiarity with sending HTTP requests (e.g., using Python's requests library).
  • Basic understanding of JSON formatting for constructing input payloads.

Authentication typically involves passing your API key in the headers of your requests, allowing you to securely access the Cognitive Actions capabilities.

Cognitive Actions Overview

Generate Custom Images with Inpainting

This action utilizes the 'dev' and 'schnell' models to create customized images based on specific prompts. It supports features like image-to-image transformation and inpainting, allowing developers to generate high-quality visuals quickly or with more intricate details.

Input

The input for this action is structured as follows:

  • prompt (required): A text prompt guiding the image generation.
  • model (optional): Specifies the model to use for inference (dev or schnell).
  • aspectRatio (optional): The aspect ratio of the generated image.
  • width (optional): Custom width for the image (only if aspect ratio is 'custom').
  • height (optional): Custom height for the image (only if aspect ratio is 'custom').
  • mask (optional): URI for the image mask used in inpainting mode.
  • image (optional): URI for an input image for image-to-image transformation.
  • guidanceScale (optional): Adjusts the guidance scale for the diffusion process.
  • outputFormat (optional): Specifies the file format of the output image (e.g., webp, jpg, png).
  • outputQuality (optional): Quality level for output images.
  • numberOfOutputs (optional): Number of images to generate.
  • numberOfInferenceSteps (optional): Number of denoising steps for image generation.

Here’s an example of the JSON payload needed to invoke this action:

{
  "model": "dev",
  "prompt": "Cinematic frame of man NEOCORTEZ in abandoned warehouse, shaft of light cutting through dust particles, short curly hair casting dramatic shadows, tactical gear visible, tense stance, horror thriller atmosphere, Fincher-style composition, desaturated color palette",
  "aspectRatio": "16:9",
  "outputFormat": "png",
  "guidanceScale": 3,
  "outputQuality": 80,
  "numberOfOutputs": 1,
  "numberOfInferenceSteps": 28
}

Output

The output of this action is typically a list of image URLs, providing direct access to the generated images. For example, you might receive a response like:

[
  "https://assets.cognitiveactions.com/invocations/52fe2dba-95c6-4a45-ac4e-53274ea3ac43/8ab54542-3ca3-42e8-abf7-4b397716cd4d.png"
]

Conceptual Usage Example (Python)

To illustrate how to call this action, here’s a conceptual Python code snippet:

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 = "bb293328-e6d2-4b32-a19c-0cba465b1a73"  # Action ID for Generate Custom Images with Inpainting

# Construct the input payload based on the action's requirements
payload = {
    "model": "dev",
    "prompt": "Cinematic frame of man NEOCORTEZ in abandoned warehouse, shaft of light cutting through dust particles, short curly hair casting dramatic shadows, tactical gear visible, tense stance, horror thriller atmosphere, Fincher-style composition, desaturated color palette",
    "aspectRatio": "16:9",
    "outputFormat": "png",
    "guidanceScale": 3,
    "outputQuality": 80,
    "numberOfOutputs": 1,
    "numberOfInferenceSteps": 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, we define the action's ID and construct the input payload according to the action's specifications. The headers include the API key for authentication, and we send a POST request to execute the action. The output is printed in a readable format for easy access to the generated image URLs.

Conclusion

The Generate Custom Images with Inpainting action in the desrucprince/neocortez API offers developers an exciting opportunity to create customized visual content tailored to their application's needs. By leveraging the flexibility of text prompts and various configuration options, you can produce high-quality images that enhance user experience and engagement. As you explore this cognitive action, consider implementing it in your projects to unlock new creative possibilities!