Generate Stunning Images with drrhinoai/aitori Cognitive Actions

23 Apr 2025
Generate Stunning Images with drrhinoai/aitori Cognitive Actions

In the realm of artificial intelligence, image generation has emerged as a powerful tool for developers looking to create visually compelling content. The drrhinoai/aitori API offers a set of Cognitive Actions designed to streamline the process of generating images based on text prompts and optional image inputs. By leveraging these pre-built actions, developers can quickly implement sophisticated image generation features into their applications, enhancing user experience and creativity.

Prerequisites

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

  • An API key for accessing the drrhinoai/aitori Cognitive Actions platform.
  • Basic knowledge of making API calls using JSON.
  • Familiarity with Python for conceptual code examples.

To authenticate your requests, you will typically include your API key in the headers of your API calls. This allows you to securely access and utilize the Cognitive Actions.

Cognitive Actions Overview

Generate AI-Assisted Image

The Generate AI-Assisted Image action allows you to create images based on a provided textual prompt. This action supports image inpainting, where an existing image can be modified based on a mask, and adjustable parameters such as width, height, and output format can be specified. The action utilizes two models, 'dev' for quality and 'schnell' for speed, making it flexible and efficient for different use cases.

Input

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

  • prompt (string): A detailed text description for the image.
    Example: "AITORI, an elite swimwear model, is standing at the rail of a yacht..."
  • mask (string, optional): URI for an image mask used in inpainting mode.
  • seed (integer, optional): Random seed for deterministic generation.
  • image (string, optional): URI for an input image.
  • width (integer, optional): Width of the generated image in pixels (256-1440).
  • height (integer, optional): Height of the generated image in pixels (256-1440).
  • loraScale (number, optional): Influence level of the primary LoRA model (default 1).
  • outputCount (integer, optional): Total number of images to generate (1-4).
  • guidanceScale (number, optional): Intensity of guidance (0-10).
  • outputQuality (integer, optional): Image quality (0-100).
  • enableFastMode (boolean, optional): Enables faster predictions (default false).
  • inferenceModel (string, optional): Selects the inference model, either 'dev' or 'schnell' (default 'dev').
  • imageAspectRatio (string, optional): Sets the aspect ratio for the image.
  • imageOutputFormat (string, optional): Format of the output images (webp, jpg, png).
  • inferenceStepCount (integer, optional): Specifies the number of denoising steps (1-50).
Example Input
{
  "prompt": "AITORI, an elite swimwear model, is standing at the rail of a yacht, admiring the panoramic view of the blue-green ocean.",
  "loraScale": 1,
  "outputCount": 1,
  "guidanceScale": 3,
  "outputQuality": 80,
  "enableFastMode": false,
  "inferenceModel": "dev",
  "imageAspectRatio": "1:1",
  "imageOutputFormat": "webp",
  "inferenceStepCount": 28
}

Output

The action returns a list of image URLs generated based on the input parameters.

Example Output
[
  "https://assets.cognitiveactions.com/invocations/0ab8e866-4be3-4064-976b-4cb98cddd995/0d5fa17d-38a6-4540-a180-e95c98e80cf0.webp"
]

Conceptual Usage Example (Python)

Here’s how you can invoke the Generate AI-Assisted Image 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 = "cf3d8917-9d69-4d74-84f6-17407d36ef43"  # Action ID for Generate AI-Assisted Image

# Construct the input payload based on the action's requirements
payload = {
    "prompt": "AITORI, an elite swimwear model, is standing at the rail of a yacht, admiring the panoramic view of the blue-green ocean.",
    "loraScale": 1,
    "outputCount": 1,
    "guidanceScale": 3,
    "outputQuality": 80,
    "enableFastMode": False,
    "inferenceModel": "dev",
    "imageAspectRatio": "1:1",
    "imageOutputFormat": "webp",
    "inferenceStepCount": 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 code snippet, replace YOUR_COGNITIVE_ACTIONS_API_KEY with your actual API key. The action ID and input payload are structured according to the specifications discussed.

Conclusion

The Generate AI-Assisted Image action from the drrhinoai/aitori API provides an excellent opportunity for developers to easily integrate sophisticated image generation capabilities into their applications. By utilizing the flexibility of prompts and adjustable parameters, you can create unique visual content tailored to your application's needs.

Explore the possibilities of AI-assisted creativity and consider implementing these Cognitive Actions to elevate your projects. Happy coding!