Generate Stunning Images with Cognitive Actions from sundai-club/rand_ted_comi_ai

23 Apr 2025
Generate Stunning Images with Cognitive Actions from sundai-club/rand_ted_comi_ai

In the world of AI and machine learning, generating high-quality images from textual descriptions has become increasingly accessible and powerful. The sundai-club/rand_ted_comi_ai provides a robust Cognitive Action that allows developers to create stunning visuals using a fine-tuned FLUX.1 model. This action not only enhances creativity by transforming words into images but also offers customization options such as aspect ratio, resolution, and output format. By leveraging these pre-built actions, developers can integrate advanced image generation capabilities into their applications effortlessly.

Prerequisites

To get started with the Cognitive Actions from sundai-club/rand_ted_comi_ai, ensure you have the following:

  • API Key: Obtain your API key for accessing the Cognitive Actions platform.
  • Access Setup: Ensure you can pass this API key in the request headers for authentication.

Authentication is typically handled by including an Authorization header with the value Bearer YOUR_API_KEY in your requests.

Cognitive Actions Overview

Generate Image with FLUX.1

Description: This action utilizes a fine-tuned FLUX.1 model to generate high-quality images based on textual prompts. It supports various customization parameters such as aspect ratio, resolution, and output format, as well as features like LoRA adjustments and a fast generation mode.

Category: Image Generation

Input

The input for this action must adhere to the following schema:

  • Required:
    • prompt: A string that describes the image you want to generate.
  • Optional:
    • mask: An image mask for inpainting mode (URI format).
    • seed: An integer for reproducible generation.
    • image: Input image for image-to-image or inpainting mode (URI format).
    • model: Select between "dev" or "schnell" (default is "dev").
    • width: Width of the generated image (must be between 256 and 1440).
    • height: Height of the generated image (must be between 256 and 1440).
    • goFast: Boolean to enable fast mode (default is false).
    • guidanceScale: A number to guide the diffusion process (default is 3).
    • mainLoraScale: Determines the strength of the main LoRA application (default is 1).
    • additionalLora: Load additional LoRA weights from various sources.
    • promptStrength: Strength of the prompt when using image-to-image (default is 0.8).
    • numberOfOutputs: Number of images to generate (between 1 and 4).
    • imageAspectRatio: Aspect ratio of the image (default is "1:1").
    • imageOutputFormat: The format of the output images (options: "webp", "jpg", "png").
    • numInferenceSteps: Number of denoising steps for image generation (default is 28).
    • imageOutputQuality: Output image quality (default is 80).
    • additionalLoraScale: Strength of the additional LoRA application (default is 1).
    • disableSafetyChecker: Boolean to disable the safety checker (default is false).
    • approximateMegapixels: Set the approximate number of megapixels for the generated image (default is "1").

Example Input:

{
  "model": "dev",
  "goFast": false,
  "prompt": "tecomiai in a rugged cyberpunk outfit leans casually against the hood of a sleek, neon-lit car as it speeds through a chaotic urban sprawl of towering holograms and glowing advertisements.",
  "guidanceScale": 3,
  "mainLoraScale": 1,
  "promptStrength": 0.8,
  "numberOfOutputs": 1,
  "imageAspectRatio": "1:1",
  "imageOutputFormat": "webp",
  "numInferenceSteps": 28,
  "imageOutputQuality": 80,
  "additionalLoraScale": 1,
  "approximateMegapixels": "1"
}

Output

The action returns a list containing the URLs of the generated images.

Example Output:

[
  "https://assets.cognitiveactions.com/invocations/ccfa74e2-5266-49dd-93f7-964af743c723/5bb62fdb-9824-4033-9eb1-3bd13deb54bc.webp"
]

Conceptual Usage Example (Python)

Here's how you can call the Generate Image with FLUX.1 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 = "80726c7f-e5a2-4633-9acb-f22bd97181f8"  # Action ID for Generate Image with FLUX.1

# Construct the input payload based on the action's requirements
payload = {
    "model": "dev",
    "goFast": False,
    "prompt": "tecomiai in a rugged cyberpunk outfit leans casually against the hood of a sleek, neon-lit car as it speeds through a chaotic urban sprawl of towering holograms and glowing advertisements.",
    "guidanceScale": 3,
    "mainLoraScale": 1,
    "promptStrength": 0.8,
    "numberOfOutputs": 1,
    "imageAspectRatio": "1:1",
    "imageOutputFormat": "webp",
    "numInferenceSteps": 28,
    "imageOutputQuality": 80,
    "additionalLoraScale": 1,
    "approximateMegapixels": "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 code snippet, replace YOUR_COGNITIVE_ACTIONS_API_KEY with your actual API key. The action ID for Generate Image with FLUX.1 is specified, and the input payload is structured according to the schema provided. The output will yield the URLs of the generated images.

Conclusion

The Cognitive Actions provided by sundai-club/rand_ted_comi_ai empower developers to generate visually striking images from textual descriptions with ease. By utilizing the flexible parameters and advanced features of the Generate Image with FLUX.1 action, you can enhance your applications' capabilities and engage users in new and creative ways. Explore further use cases, integrate these actions into your projects, and unleash your creativity!