Harnessing Creativity: Generate Stunning Images with the Flux My Subconscious Cognitive Actions

21 Apr 2025
Harnessing Creativity: Generate Stunning Images with the Flux My Subconscious Cognitive Actions

In the world of AI-driven creativity, the fofr/flux-my-subconscious API offers developers powerful Cognitive Actions designed to transform imaginative prompts into stunning visual representations. With a focus on speed and quality, these actions leverage a fine-tuned model to generate images that can be used in various applications. By integrating these pre-built actions, developers can easily harness the capabilities of image generation, enabling innovative features in their projects.

Prerequisites

Before diving into the Cognitive Actions, ensure you have the following:

  • An API key for the Cognitive Actions platform.
  • Basic knowledge of JSON and HTTP requests.
  • A development environment set up for making API calls (e.g., Python with the requests library).

Authentication typically involves passing your API key in the headers of your requests.

Cognitive Actions Overview

Generate Image With Flux Subconscious

The Generate Image With Flux Subconscious action allows you to create images based on a textual prompt. This action supports both image-to-image transformation and inpainting modes, providing flexibility through adjustable parameters such as image quality, aspect ratio, and model inference steps.

Input

The input for this action is structured as a JSON object, requiring the following fields:

  • prompt (required): A textual description for the image. For optimal results, including the trigger word from the training process is recommended.

Optional fields include:

  • model: Specifies which model to use for inference. The default is "dev".
  • goFast: A boolean that, when set to true, optimizes for speed using fp8 quantization.
  • image: An input image for image-to-image or inpainting mode.
  • width and height: Dimensions for the generated image, applicable only with a custom aspect ratio.
  • imageOutputFormat: Format of the output images (e.g., "webp", "jpg", "png").

Here’s an example of a complete input payload:

{
  "model": "dev",
  "goFast": false,
  "prompt": "MY_SUBCONSCIOUS ",
  "loraScale": 1,
  "megapixels": "1",
  "numberOfOutputs": 1,
  "imageOutputFormat": "webp",
  "aspectRatioSetting": "1:1",
  "imageGuidanceScale": 3,
  "imageOutputQuality": 80,
  "inferenceStepCount": 28,
  "additionalLoraScale": 1,
  "imagePromptStrength": 0.8
}

Output

The output of this action is a URL to the generated image. An example of a typical output is:

[
  "https://assets.cognitiveactions.com/invocations/302828ba-4079-4943-af2d-c645d560cfb0/5f022de0-f90c-40f8-bb66-0530ae9ad694.webp"
]

Conceptual Usage Example (Python)

Here's how you can invoke the Generate Image With Flux Subconscious 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 = "5c5a740f-73fd-4163-85eb-3e4a3cf8cccd"  # Action ID for Generate Image With Flux Subconscious

# Construct the input payload based on the action's requirements
payload = {
    "model": "dev",
    "goFast": False,
    "prompt": "MY_SUBCONSCIOUS ",
    "loraScale": 1,
    "megapixels": "1",
    "numberOfOutputs": 1,
    "imageOutputFormat": "webp",
    "aspectRatioSetting": "1:1",
    "imageGuidanceScale": 3,
    "imageOutputQuality": 80,
    "inferenceStepCount": 28,
    "additionalLoraScale": 1,
    "imagePromptStrength": 0.8
}

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 snippet, replace "YOUR_COGNITIVE_ACTIONS_API_KEY" with your actual API key. The action_id variable corresponds to the "Generate Image With Flux Subconscious" action. The payload is structured to align with the required input schema, ensuring correct execution.

Conclusion

By integrating the Generate Image With Flux Subconscious Cognitive Action into your applications, you can unlock a world of creative possibilities, generating unique images from textual prompts with ease. Whether you're looking to enhance your app's visual storytelling or explore artistic expressions, these actions provide a seamless way to bring your ideas to life. Start experimenting today and see how AI can transform creativity in your projects!