Generate Stunning Images Effortlessly with Aakash Generator's Cognitive Actions

23 Apr 2025
Generate Stunning Images Effortlessly with Aakash Generator's Cognitive Actions

In the world of AI and image generation, the Aakash Generator provides developers with powerful tools to create and manipulate images using Cognitive Actions. Leveraging these pre-built actions allows you to maximize productivity by integrating image generation capabilities into your applications without the need for extensive model training or complex setups. In this post, we will explore how to utilize the Generate Aakash Images action, detailing its inputs, outputs, and providing a conceptual usage example in Python.

Prerequisites

Before getting started, ensure you have the following:

  • An API key for accessing the Cognitive Actions platform.
  • Basic understanding of making API requests and handling JSON data.
  • Familiarity with Python for implementing the provided code examples.

Authentication is typically handled by including your API key in the request headers, which grants access to the Cognitive Actions you intend to utilize.

Cognitive Actions Overview

Generate Aakash Images

The Generate Aakash Images action allows you to create images by providing customized parameters such as size, quality, and model options. This action also supports image-to-image transformation and inpainting, making it a versatile tool for a wide range of applications.

Input

The input for this action is defined by the following schema:

{
  "prompt": "string (required)",
  "mask": "string (optional)",
  "seed": "integer (optional)",
  "image": "string (optional)",
  "width": "integer (optional)",
  "goFast": "boolean (optional)",
  "height": "integer (optional)",
  "aspectRatio": "string (optional)",
  "outputFormat": "string (optional)",
  "guidanceScale": "number (optional)",
  "outputQuality": "integer (optional)",
  "numOutputs": "integer (optional)",
  "extraLora": "string (optional)",
  "loraScale": "number (optional)",
  "extraLoraScale": "number (optional)",
  "inferenceModel": "string (optional)",
  "promptStrength": "number (optional)",
  "imageMegapixels": "string (optional)",
  "mainLoraWeights": "string (optional)",
  "numInferenceSteps": "integer (optional)",
  "disableSafetyChecker": "boolean (optional)"
}

Here’s an example input JSON payload:

{
  "goFast": false,
  "prompt": "@@k@$h@ running",
  "loraScale": 1,
  "numOutputs": 1,
  "aspectRatio": "1:1",
  "outputFormat": "webp",
  "guidanceScale": 3,
  "outputQuality": 80,
  "extraLoraScale": 1,
  "inferenceModel": "dev",
  "promptStrength": 0.8,
  "imageMegapixels": "1",
  "numInferenceSteps": 28
}

Output

The action returns a URL pointing to the generated image. Here’s an example of the output you might receive:

[
  "https://assets.cognitiveactions.com/invocations/f9bbaa6c-5d41-451a-9f4f-d8d56ea6562a/3b9945fd-b2d8-4e62-a642-a3fe8c230f6f.webp"
]

Conceptual Usage Example (Python)

Below is a conceptual example demonstrating how you might call the Cognitive Actions endpoint for generating Aakash images 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 = "7a7cf85d-61ba-4d43-a970-36619f2df8b7"  # Action ID for Generate Aakash Images

# Construct the input payload based on the action's requirements
payload = {
    "goFast": False,
    "prompt": "@@k@$h@ running",
    "loraScale": 1,
    "numOutputs": 1,
    "aspectRatio": "1:1",
    "outputFormat": "webp",
    "guidanceScale": 3,
    "outputQuality": 80,
    "extraLoraScale": 1,
    "inferenceModel": "dev",
    "promptStrength": 0.8,
    "imageMegapixels": "1",
    "numInferenceSteps": 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 payload object is constructed based on the required and optional fields for the action.
  • The request is sent to the hypothetical endpoint, and the response is processed.

Conclusion

The Generate Aakash Images action opens up a world of possibilities for developers looking to integrate sophisticated image generation capabilities into their applications. By leveraging customizable parameters, you can create images tailored to your specific needs, whether for artistic projects, marketing materials, or innovative prototypes.

As you explore further, consider experimenting with different parameters like numOutputs and guidanceScale to refine your image generation results. The integration of such powerful tools can significantly enhance the creative possibilities of your applications. Happy coding!