Create Stunning Custom Images with bagustianxx/zenixloraflux Cognitive Actions

23 Apr 2025
Create Stunning Custom Images with bagustianxx/zenixloraflux Cognitive Actions

In today's digital landscape, the ability to generate high-quality images from text prompts opens up exciting possibilities for developers. The bagustianxx/zenixloraflux API offers a powerful Cognitive Action called Generate Custom Images that allows you to create images tailored to your specifications. This action provides a robust set of options, ensuring that developers can produce stunning visuals for their applications with minimal effort.

Prerequisites

Before you start using the Generate Custom Images action, ensure you have the following:

  • API Key: You will need an API key to authenticate your requests to the Cognitive Actions platform. This key should be included in the headers of your API calls.
  • Basic Understanding of JSON: Familiarity with JSON is essential, as the input and output will be structured in this format.

Authentication can typically be handled by passing the API key as a Bearer token in the request headers.

Cognitive Actions Overview

Generate Custom Images

The Generate Custom Images action creates images based on a provided text prompt, allowing customization of various features such as image size, aspect ratio, and format. Users can choose between different models—'dev' for quality and 'schnell' for speed—along with additional options like LoRA intensities and safety checks.

Input

The input for this action is structured as a JSON object with the following schema:

  • prompt (required): A string that describes the image you want to generate.
  • model: (optional) Select between "dev" or "schnell" for inference.
  • width and height: (optional) Specify the dimensions of the image (if aspect_ratio is custom).
  • aspect_ratio: (optional) Choose the aspect ratio for the image.
  • numberOfOutputs: (optional) Define how many images to generate (default is 1).
  • Additional parameters include imageOutputFormat, imageGuidanceScale, mainLoraIntensity, and more to refine the image generation process.

Here’s an example payload for the input:

{
  "model": "dev",
  "width": 810,
  "height": 1440,
  "prompt": "Professional photograph with motion blur of a black Toyota Innova Zen1x car with 20 inch chrome luxury wheels, rolling on suburb road",
  "numberOfOutputs": 4,
  "imageAspectRatio": "9:16",
  "imageOutputFormat": "png",
  "mainLoraIntensity": 0.8,
  "imageGuidanceScale": 3.5,
  "imageOutputQuality": 90,
  "imagePromptStrength": 1,
  "numberOfDenoisingSteps": 35,
  "additionalLoraIntensity": 1
}

Output

The action returns an array of URLs pointing to the generated images. Each URL corresponds to a different output based on the specified number of outputs. Here's an example of what the output might look like:

[
  "https://assets.cognitiveactions.com/invocations/23985142-97b3-42f8-a964-32e49fac0a06/d71202c7-8e16-45c0-b7b3-9c6d43d78ba4.png",
  "https://assets.cognitiveactions.com/invocations/23985142-97b3-42f8-a964-32e49fac0a06/c39e9990-7991-40c3-8425-2b2d886cf075.png",
  "https://assets.cognitiveactions.com/invocations/23985142-97b3-42f8-a964-32e49fac0a06/273e539e-9d37-48cb-98e1-dc00efde6735.png",
  "https://assets.cognitiveactions.com/invocations/23985142-97b3-42f8-a964-32e49fac0a06/457263ed-9aa6-4d74-bb23-f642316843ee.png"
]

Conceptual Usage Example (Python)

Here’s a conceptual example of how you might 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 = "3f6eaaa1-7130-4a69-9043-49fea8ef6889"  # Action ID for Generate Custom Images

# Construct the input payload based on the action's requirements
payload = {
    "model": "dev",
    "width": 810,
    "height": 1440,
    "prompt": "Professional photograph with motion blur of a black Toyota Innova Zen1x car with 20 inch chrome luxury wheels, rolling on suburb road",
    "numberOfOutputs": 4,
    "imageAspectRatio": "9:16",
    "imageOutputFormat": "png",
    "mainLoraIntensity": 0.8,
    "imageGuidanceScale": 3.5,
    "imageOutputQuality": 90,
    "imagePromptStrength": 1,
    "numberOfDenoisingSteps": 35,
    "additionalLoraIntensity": 1
}

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, you would replace the COGNITIVE_ACTIONS_API_KEY with your actual API key. The action_id is set to the ID for the Generate Custom Images action. The constructed payload includes all necessary parameters for the image generation.

Conclusion

The Generate Custom Images action from the bagustianxx/zenixloraflux API empowers developers to easily create customized images based on text prompts. By leveraging this action, you can enhance your applications with dynamic visuals that meet your specific needs. Explore the various parameters to fine-tune the image generation process and unleash your creativity in image design!