Generate Stunning Images with My Flux Face Cognitive Actions

25 Apr 2025
Generate Stunning Images with My Flux Face Cognitive Actions

In the rapidly evolving landscape of image creation, My Flux Face offers a powerful set of Cognitive Actions designed to generate high-quality images using advanced techniques like inpainting and image-to-image transformations. These pre-built actions allow developers to leverage flexible output customization, enabling the creation of unique visuals tailored to specific requirements. Whether you are looking to enhance creative projects or automate image generation, the My Flux Face actions open up a world of possibilities.

Prerequisites

Before diving into the integration of My Flux Face Cognitive Actions, ensure you have the following prerequisites in place:

  • An API key for accessing the Cognitive Actions platform.
  • Basic knowledge of RESTful APIs and JSON payload structures.
  • Familiarity with a programming language, preferably Python, for executing API calls.

To authenticate requests, you will typically pass the API key in the request headers, allowing access to the Cognitive Actions functionality.

Cognitive Actions Overview

Generate Image with My Flux Face

Description: This action creates high-quality images using the My Flux Face operation, offering options for inpainting and image-to-image transformation. It supports various parameters for output customization, including aspect ratio, dimensions, image format, guidance scale, and more.

Category: Image Generation

Input

The input schema requires the following fields:

  • prompt (required): A string that specifies the text prompt for image generation.
  • model: Specifies the model for inference (default: "dev").
  • aspectRatio: Defines the aspect ratio for the output image (default: "1:1").
  • loraStrength: Controls the influence of the main LoRA during inference (default: 1).
  • outputFormat: Specifies the format for the output image (default: "webp").
  • guidanceScale: Adjusts the guidance scale for the diffusion process (default: 3).
  • outputQuality: Defines the quality of the output image (default: 80).
  • promptStrength: Sets the influence of the prompt in img2img generation (default: 0.8).
  • numberOfOutputs: Specifies how many output images to generate (default: 1).
  • numberOfInferenceSteps: Defines the amount of denoising steps during inference (default: 28).

Example Input:

{
  "model": "dev",
  "prompt": "High-definition portrait of JOHAN as an startup CTO, with steel glasses, well groomed, intellectual, thoughtful, confident, using casual dress",
  "aspectRatio": "1:1",
  "loraStrength": 1,
  "outputFormat": "webp",
  "guidanceScale": 3.5,
  "outputQuality": 90,
  "promptStrength": 0.8,
  "numberOfOutputs": 1,
  "numberOfInferenceSteps": 28
}

Output

The action typically returns a URL pointing to the generated image.

Example Output:

[
  "https://assets.cognitiveactions.com/invocations/212ab647-8d1f-4d94-b613-e5c47fc9fda1/fe45ff87-941f-4fba-973c-dcb1fad4d7e8.webp"
]

Conceptual Usage Example (Python)

Here’s how you might implement a call to the Generate Image with My Flux Face 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 = "e8a2a26e-3b20-4353-aed8-1e2d4353a7b8"  # Action ID for Generate Image with My Flux Face

# Construct the input payload based on the action's requirements
payload = {
    "model": "dev",
    "prompt": "High-definition portrait of JOHAN as an startup CTO, with steel glasses, well groomed, intellectual, thoughtful, confident, using casual dress",
    "aspectRatio": "1:1",
    "loraStrength": 1,
    "outputFormat": "webp",
    "guidanceScale": 3.5,
    "outputQuality": 90,
    "promptStrength": 0.8,
    "numberOfOutputs": 1,
    "numberOfInferenceSteps": 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 Python code example, we construct a JSON payload according to the action's input requirements, set the necessary headers for authentication, and make a POST request to the Cognitive Actions execution endpoint. The output is printed in a readable format.

Conclusion

The My Flux Face Cognitive Actions enable developers to harness the power of AI-driven image generation with ease. By utilizing the various parameters available, you can create stunning visuals tailored to your specific needs. Whether for creative projects or automated workflows, integrating these actions into your applications can greatly enhance your capabilities. Explore the possibilities and start generating images today!