Create Stunning Images with the andreasjansson/flux-goo Cognitive Action

24 Apr 2025
Create Stunning Images with the andreasjansson/flux-goo Cognitive Action

In the world of artificial intelligence and image generation, the ability to create high-quality images efficiently is paramount. The andreasjansson/flux-goo Cognitive Actions provide developers with a powerful tool to generate images using the FLUX.1 model, trained on Replicate goo. With various customization options, this action enables you to produce detailed images quickly and precisely. In this article, we’ll explore how to integrate this action into your applications and leverage its features for your image generation needs.

Prerequisites

To get started with the Cognitive Actions, you will need an API key for the Cognitive Actions platform. This key will be used for authentication when making requests. Conceptually, you will pass this API key in the headers of your HTTP requests to authorize access to the image generation capabilities.

Cognitive Actions Overview

Generate Image Using FLUX.1

The Generate Image Using FLUX.1 action allows you to create images by leveraging the FLUX.1 model. This operation provides a range of customization options such as aspect ratio, image format, and various parameters for fine-tuning the generated output.

  • Category: Image Generation

Input

The input for this action requires a prompt and allows for various optional parameters. Below is the schema for the input along with an example:

{
  "prompt": "PLSM style, an image of a tiger, made of yellow, red, and purple goo plasma",
  "loraScale": 1.1,
  "aspectRatio": "1:1",
  "imageFormat": "webp",
  "guidanceScale": 1.5,
  "outputQuality": 80,
  "inferenceModel": "dev",
  "inferenceSteps": 28,
  "numberOfOutputs": 1
}

Required Fields:

  • prompt: A text prompt guiding the image generation.

Optional Fields:

  • mask: URI of the image mask.
  • seed: Random seed for reproducibility.
  • image: URI of the input image for image-to-image generation.
  • width and height: Dimensions for custom aspect ratio.
  • goFast: Enable fast generation mode.
  • Additional parameters like loraWeights, guidanceScale, etc.

Output

The action typically returns a URL to the generated image. Here is an example of the output:

[
  "https://assets.cognitiveactions.com/invocations/80c096d6-72fa-462d-b689-58eaff1e6e78/d445557b-96f0-43fc-ac03-eab48dad047d.webp"
]

Conceptual Usage Example (Python)

Here’s how you might call the Generate Image Using 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 = "5d4056ea-ee1c-4d45-bab8-7a3d4c498aa1"  # Action ID for Generate Image Using FLUX.1

# Construct the input payload based on the action's requirements
payload = {
    "prompt": "PLSM style, an image of a tiger, made of yellow, red, and purple goo plasma",
    "loraScale": 1.1,
    "aspectRatio": "1:1",
    "imageFormat": "webp",
    "guidanceScale": 1.5,
    "outputQuality": 80,
    "inferenceModel": "dev",
    "inferenceSteps": 28,
    "numberOfOutputs": 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 payload variable constructs the input JSON based on the action's requirements. The endpoint URL and request structure provided here are illustrative.

Conclusion

The andreasjansson/flux-goo Cognitive Action equips developers with the tools to create stunning images using AI. By leveraging the customization options and capabilities of the FLUX.1 model, you can generate high-quality images tailored to your specifications. Explore the possibilities, experiment with different parameters, and integrate this powerful action into your applications to enhance your image generation capabilities.