Generate Stunning Custom Images with Aisha AI's Flux Actions

23 Apr 2025
Generate Stunning Custom Images with Aisha AI's Flux Actions

In the world of artificial intelligence, visual creativity is taking center stage. The Aisha AI Flux Cognitive Actions provide a powerful way to generate custom images based on user-defined text prompts. With adjustable parameters, developers can create unique visuals for their applications, making it easier to enhance user engagement and experience.

Prerequisites

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

  • An API key for the Aisha AI Cognitive Actions platform.
  • Basic knowledge of making HTTP requests and handling JSON in your preferred programming language.

For authentication, you will typically pass your API key in the request headers to authorize access to the Cognitive Actions services.

Cognitive Actions Overview

Generate Custom Images

The Generate Custom Images action allows you to create images based on text prompts provided by users. This action is categorized under image-generation and offers flexibility with parameters like image size, generation steps, and denoising algorithms.

Input

The input for this action is structured as follows:

{
  "prompt": "required string",
  "seed": "optional integer (default: -1)",
  "steps": "optional integer (default: 20, range: 4-50)",
  "width": "optional integer (default: 1024, range: 512-2048)",
  "height": "optional integer (default: 1024, range: 512-2048)",
  "scheduler": "optional string (default: 'default')",
  "configurationScale": "optional number (default: 5, range: 0-20)"
}

Example Input:

{
  "seed": -1,
  "steps": 30,
  "width": 768,
  "height": 768,
  "prompt": "on a coffee shop, a beauty waitress is wearing a sexy bunny cosplay with a big cleavage. She is holding a sign that says \"Don't stare at waitresses' breasts\"",
  "scheduler": "default",
  "configurationScale": 3
}

Output

Upon successful execution, the action returns a URL pointing to the generated image:

[
  "https://assets.cognitiveactions.com/invocations/cec9f0d5-4f43-4e07-ba34-ac5f4b15843b/a733d453-1f6c-4bca-91d4-c5101cde792d.png"
]

Conceptual Usage Example (Python)

Here’s how you can call the Generate Custom Images 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 = "e9159122-d165-4ad6-a269-1827fee6214b"  # Action ID for Generate Custom Images

# Construct the input payload based on the action's requirements
payload = {
    "seed": -1,
    "steps": 30,
    "width": 768,
    "height": 768,
    "prompt": "on a coffee shop, a beauty waitress is wearing a sexy bunny cosplay with a big cleavage. She is holding a sign that says \"Don't stare at waitresses' breasts\"",
    "scheduler": "default",
    "configurationScale": 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 example, replace YOUR_COGNITIVE_ACTIONS_API_KEY and the hypothetical endpoint with your actual API key and endpoint. The action ID and the payload structure are included to guide the correct input formation.

Conclusion

The Aisha AI's Flux Cognitive Actions offer an exciting way to incorporate image generation capabilities into your applications. By leveraging the Generate Custom Images action, developers can create engaging visuals tailored to user preferences. Whether you're aiming to enhance a website, create marketing materials, or develop unique digital content, these Cognitive Actions provide a robust framework to help you achieve your goals. Start integrating today and explore the endless creative possibilities!