Generate Stunning Images with Aisha AI's Realism IL v3 Cognitive Actions

22 Apr 2025
Generate Stunning Images with Aisha AI's Realism IL v3 Cognitive Actions

In the world of artificial intelligence, image generation has seen tremendous advancements, allowing developers to create high-quality, realistic visuals from simple prompts. The Aisha AI Realism IL v3 API provides powerful Cognitive Actions for generating stunning images tailored to your specifications. This guide will walk you through utilizing these actions, specifically focusing on the Generate Realistic Image action, to enhance your applications with advanced image generation capabilities.

Prerequisites

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

  • An API key for the Aisha AI Cognitive Actions platform.
  • Basic understanding of JSON and Python for making API calls.

Authentication typically involves passing your API key in the request headers, enabling secure access to the Cognitive Actions functionalities.

Cognitive Actions Overview

Generate Realistic Image

The Generate Realistic Image action utilizes the Realism-IL-v3 model to produce high-quality images based on your input prompts. This action allows customization across various parameters, enhancing the control you have over the generated output.

Input:

The input for this action is structured as follows:

  • seed (integer): Controls randomness. Set to -1 for random seed.
  • model (string): Should be set to "Realism-IL-v3".
  • steps (integer): Number of steps for image generation (1-100).
  • width (integer): Width of the image in pixels (1-4096).
  • height (integer): Height of the image in pixels (1-4096).
  • prompt (string): Text guiding the generation, utilizing Compel weighting syntax.
  • scheduler (string): Type of scheduler used during generation. Default is "Euler a".
  • clipLayerSkip (integer): Number of CLIP layers to skip.
  • imageBatchSize (integer): Number of images generated per batch (1-4).
  • prependPreprompt (boolean): Prepend a preprompt to the input.
  • configurationScale (number): Determines model's attention to the prompt.
  • guidanceRescaleAmount (number): Rescales CFG-generated noise.
  • variationalAutoencoder (string): Selects the VAE model.
  • negativePromptInstructions (string): Negative elements to avoid in the output.
  • progressiveAttentionalGuidanceScale (number): Enhances result quality.

Here’s an example input JSON payload:

{
  "seed": -1,
  "model": "Realism-IL-v3",
  "steps": 30,
  "width": 1024,
  "height": 1024,
  "prompt": "street, 1girl, dark-purple short hair, purple eyes, medium breasts, cleavage, casual clothes, smile, V, closeup",
  "scheduler": "Euler a",
  "clipLayerSkip": 1,
  "imageBatchSize": 1,
  "prependPreprompt": true,
  "configurationScale": 5,
  "guidanceRescaleAmount": 0.5,
  "variationalAutoencoder": "default",
  "negativePromptInstructions": "nsfw, naked",
  "progressiveAttentionalGuidanceScale": 3
}

Output:

Upon successful execution, this action returns a URL linking to the generated image. Here’s an example of a typical output:

[
  "https://assets.cognitiveactions.com/invocations/d46e41ab-f017-43eb-8b8c-279a2cb2b079/03cafce8-1d6e-4c2a-900a-7057b04b7644.png"
]

Conceptual Usage Example (Python):

Here’s a conceptual Python snippet demonstrating how to call the Cognitive Actions endpoint for generating a realistic image:

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 = "b49b4dba-b3aa-4f0c-9ddd-c6851fb47c3f" # Action ID for Generate Realistic Image

# Construct the input payload based on the action's requirements
payload = {
    "seed": -1,
    "model": "Realism-IL-v3",
    "steps": 30,
    "width": 1024,
    "height": 1024,
    "prompt": "street, 1girl, dark-purple short hair, purple eyes, medium breasts, cleavage, casual clothes, smile, V, closeup",
    "scheduler": "Euler a",
    "clipLayerSkip": 1,
    "imageBatchSize": 1,
    "prependPreprompt": True,
    "configurationScale": 5,
    "guidanceRescaleAmount": 0.5,
    "variationalAutoencoder": "default",
    "negativePromptInstructions": "nsfw, naked",
    "progressiveAttentionalGuidanceScale": 3
}

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, ensure you replace the COGNITIVE_ACTIONS_API_KEY and COGNITIVE_ACTIONS_EXECUTE_URL with your actual credentials and endpoint. The payload variable contains the structured input needed to call the action.

Conclusion

The Generate Realistic Image action from Aisha AI's Realism IL v3 API offers developers exciting opportunities to create visually rich applications. By leveraging customizable parameters, you can produce stunning images that meet your specific needs. To explore further, consider experimenting with different prompts and parameters to see the vast range of images you can generate. Happy coding!