Generate Stunning Images with FLUX 1.1 Pro Cognitive Actions

22 Apr 2025
Generate Stunning Images with FLUX 1.1 Pro Cognitive Actions

In the world of image generation, the FLUX 1.1 Pro model offers an innovative solution for developers looking to transform text prompts into high-quality images with remarkable adherence to user-defined specifications. By leveraging these pre-built Cognitive Actions, you can easily integrate sophisticated text-to-image capabilities into your applications, enhancing user experience and creativity. This article will guide you through the key features of the FLUX 1.1 Pro action and how to utilize it effectively.

Prerequisites

To begin using the FLUX 1.1 Pro Cognitive Actions, you will need an API key to authenticate your requests. Typically, this involves passing your API key in the request headers as a Bearer token. Ensure that you have the necessary setup in place to call the Cognitive Actions API.

Cognitive Actions Overview

Generate Image with FLUX1.1 Pro

The Generate Image with FLUX1.1 Pro action allows developers to harness the power of the FLUX1.1 Pro model for rapid and high-quality text-to-image generation. This action offers improved prompt adherence and output diversity, making it an excellent choice for various creative applications.

Input

The input for this action requires a JSON object that adheres to the following schema:

  • prompt (string, required): A textual prompt guiding the image generation process.
    Example: "black forest gateau cake spelling out the words 'FLUX 1 . 1 Pro', tasty, food photography"
  • seed (integer, optional): A random seed for reproducible results in image generation.
  • width (integer, optional): Specifies the generated image's width (must be a multiple of 32).
  • height (integer, optional): Specifies the generated image's height (must be a multiple of 32).
  • guideImage (string, optional): URI of an image to influence the generated output.
  • aspectRatio (string, optional): Aspect ratio options (e.g., "1:1", "16:9", or "custom").
    Default: "1:1"
  • outputFormat (string, optional): Format of the output image (options include "webp", "jpg", "png").
    Default: "webp"
  • outputQuality (integer, optional): Quality of the output image (0 to 100).
    Default: 80
  • safetyTolerance (integer, optional): Defines the safety level for image generation (1 to 6).
    Default: 2
  • promptUpsampling (boolean, optional): Enhances creative output by modifying the prompt automatically.
    Default: false

Example Input:

{
  "prompt": "black forest gateau cake spelling out the words \"FLUX 1 . 1 Pro\", tasty, food photography",
  "aspectRatio": "1:1",
  "outputFormat": "webp",
  "outputQuality": 80,
  "safetyTolerance": 2,
  "promptUpsampling": true
}

Output

Upon successful execution, the action returns a URL pointing to the generated image. The output might look like this:

Example Output:

https://assets.cognitiveactions.com/invocations/eaeec8b8-27d2-4a91-9a86-6daeb689b64c/20e21ddb-4989-4d1a-96e3-41437ed1c505.webp

Conceptual Usage Example (Python)

Here’s a conceptual Python code snippet demonstrating how to call the FLUX1.1 Pro action to generate an image:

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 = "900ff4a7-131f-4a86-87a3-417d093b584a"  # Action ID for Generate Image with FLUX1.1 Pro

# Construct the input payload based on the action's requirements
payload = {
    "prompt": "black forest gateau cake spelling out the words \"FLUX 1 . 1 Pro\", tasty, food photography",
    "aspectRatio": "1:1",
    "outputFormat": "webp",
    "outputQuality": 80,
    "safetyTolerance": 2,
    "promptUpsampling": True
}

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, the action ID and input payload are clearly defined, allowing developers to customize their requests. Note that the endpoint URL and request structure are illustrative, and adjustments may be necessary based on actual implementation.

Conclusion

The FLUX 1.1 Pro Cognitive Action for generating images offers a powerful and flexible solution for developers looking to incorporate visual creativity into their applications. By understanding how to structure inputs and handle outputs, you can seamlessly enhance user engagement through stunning image generation. Explore further use cases and start integrating these capabilities into your projects today!