Enhance Your Application with Image Generation Using jarvis-labs2024/flux-raylene Cognitive Actions

21 Apr 2025
Enhance Your Application with Image Generation Using jarvis-labs2024/flux-raylene Cognitive Actions

In the ever-evolving world of AI, image generation has become an essential component for developers looking to add unique visual elements to their applications. The jarvis-labs2024/flux-raylene API offers a suite of Cognitive Actions specifically designed for advanced image generation. These pre-built actions empower developers to create stunning images with various customizable parameters, enabling enhanced creativity and functionality in applications.

Prerequisites

To use the Cognitive Actions provided by the jarvis-labs2024/flux-raylene API, you'll need an API key for authentication. This key is typically passed in the request headers to authorize your calls to the cognitive actions endpoint. Ensure you have the necessary setup to make HTTP requests from your application.

Cognitive Actions Overview

Generate Enhanced Image

The Generate Enhanced Image action allows you to generate images using advanced AI models, offering customizable parameters like aspect ratio, image quality, and output format. This action supports image inpainting and fast image generation modes, optimizing for both speed and quality.

Input

The action requires a JSON payload structured according to the following schema:

  • prompt (required): A description that guides the image generation.
  • mask (optional): An image mask for inpainting mode, ignoring other dimensions.
  • seed (optional): An integer for reproducible generation.
  • image (optional): An input image for image-to-image or inpainting mode.
  • width (optional): Width of the generated image in pixels (applies only with custom aspect ratio).
  • height (optional): Height of the generated image in pixels (applies only with custom aspect ratio).
  • goFast (optional): A boolean to enable faster image generation.
  • guidanceScale (optional): Controls the guidance scale during generation.
  • numOutputs (optional): Number of images to generate.
  • outputQuality (optional): Quality scale for output images.
  • imageAspectRatio (optional): Aspect ratio for the image.
  • imageOutputFormat (optional): Format of the output images.

Here's an example JSON payload to invoke the action:

{
  "prompt": "beautiful anime artwork, a cute anime catgirl that looks depressed holding a piece of paper with a smile drawn on it over her mouth, she is about to cry",
  "loraScale": 1,
  "numOutputs": 4,
  "guidanceScale": 3.5,
  "outputQuality": 80,
  "inferenceModel": "dev",
  "imageAspectRatio": "1:1",
  "imageOutputFormat": "webp",
  "numInferenceSteps": 28
}

Output

The action returns an array of URLs pointing to the generated images. Here is an example of what the output might look like:

[
  "https://assets.cognitiveactions.com/invocations/6a0c0d26-7a0f-4417-b4a0-1a0a7f2ad2fb/fa67de29-36b0-4311-9a99-68fd4e2af710.webp",
  "https://assets.cognitiveactions.com/invocations/6a0c0d26-7a0f-4417-b4a0-1a0a7f2ad2fb/e159aece-bb95-4865-a821-57114494c379.webp",
  "https://assets.cognitiveactions.com/invocations/6a0c0d26-7a0f-4417-b4a0-1a0a7f2ad2fb/7c69e6f2-a757-4a74-b7a1-48f69da1dd8e.webp",
  "https://assets.cognitiveactions.com/invocations/6a0c0d26-7a0f-4417-b4a0-1a0a7f2ad2fb/c457e19f-4308-4847-82cb-04298c0ad57a.webp"
]

Conceptual Usage Example (Python)

Here's how you might call the Generate Enhanced Image action using a hypothetical endpoint in 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 = "00fd05ea-7bdb-4e45-a1f1-202f54681562"  # Action ID for Generate Enhanced Image

# Construct the input payload based on the action's requirements
payload = {
    "prompt": "beautiful anime artwork, a cute anime catgirl that looks depressed holding a piece of paper with a smile drawn on it over her mouth, she is about to cry",
    "loraScale": 1,
    "numOutputs": 4,
    "guidanceScale": 3.5,
    "outputQuality": 80,
    "inferenceModel": "dev",
    "imageAspectRatio": "1:1",
    "imageOutputFormat": "webp",
    "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 example, you'll need to replace "YOUR_COGNITIVE_ACTIONS_API_KEY" with your actual API key. The action ID and input payload are structured according to the requirements of the Generate Enhanced Image action. The endpoint URL is illustrative, and you should adjust it as necessary for your implementation.

Conclusion

The jarvis-labs2024/flux-raylene Cognitive Actions provide powerful capabilities for image generation, allowing developers to enhance their applications with unique visuals. By leveraging the Generate Enhanced Image action, you can create customized images tailored to your needs, improving user engagement and experience. Start integrating these actions into your projects today to unlock the potential of AI-driven image generation!