Unlocking Image Generation with the OSTRIS FLUX.1-dev Cognitive Actions

24 Apr 2025
Unlocking Image Generation with the OSTRIS FLUX.1-dev Cognitive Actions

In the realm of AI-powered image creation, the OSTRIS FLUX.1-dev Cognitive Actions provide a robust framework for developers looking to leverage advanced image generation techniques. By utilizing these pre-built actions, developers can fine-tune the FLUX.1-dev model, enhancing image quality and enabling features like inpainting and customizable dimensions, all while simplifying the integration process into their applications.

Prerequisites

To get started with the OSTRIS FLUX.1-dev Cognitive Actions, you'll need an API key from the Cognitive Actions platform. This key will be used for authentication by passing it in the request headers. Make sure your development environment is set up to make HTTP requests, as you'll be interacting with the Cognitive Actions API to execute the image generation tasks.

Cognitive Actions Overview

Fine-Tune FLUX.1-dev with AI Toolkit

The Fine-Tune FLUX.1-dev with AI Toolkit action is designed to fine-tune the FLUX.1-dev model, enhancing its capabilities for image generation. This action supports inpainting and img2img modes, allowing for a high degree of customization based on user input.

Input

The input schema for this action is a JSON object that requires the following fields:

  • prompt (string, required): The text prompt guiding the image generation. Using trigger words from the training process can improve results.
  • model (string, optional): Specify which model to use for inference, either 'dev' (default) or 'schnell'.
  • aspectRatio (string, optional): The aspect ratio for the generated image; defaults to '1:1'.
  • outputFormat (string, optional): The desired output format for the generated image (e.g., 'webp', 'jpg', 'png').
  • guidanceScale (number, optional): Controls the guidance during image generation, with a default of 3.5.
  • mainLoraScale (number, optional): Determines the strength of the main LoRA application, defaulting to 1.
  • outputQuality (integer, optional): Specifies the quality of the output image, ranging from 0 to 100.
  • numberOfOutputs (integer, optional): Indicates how many images to generate, with a default of 1.
  • inferenceStepCount (integer, optional): Defines the number of inference steps, affecting detail in the generated image.

Example Input:

{
  "model": "dev",
  "prompt": "puppy",
  "aspectRatio": "1:1",
  "outputFormat": "webp",
  "guidanceScale": 3.5,
  "mainLoraScale": 1,
  "outputQuality": 80,
  "numberOfOutputs": 1,
  "inferenceStepCount": 28
}

Output

When executing this action, the output will be a JSON object containing an array of URLs pointing to the generated images. For example:

Example Output:

[
  "https://assets.cognitiveactions.com/invocations/c9814b71-b7e7-478f-af57-c4664c13cab8/2f0da460-727c-4b8a-886f-e8cdade15ca1.webp"
]

Conceptual Usage Example (Python)

Here’s a conceptual example of how to invoke the Fine-Tune FLUX.1-dev with AI Toolkit 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 = "f29fa2f4-5726-432d-a7f8-ba0d47f74ff7"  # Action ID for Fine-Tune FLUX.1-dev with AI Toolkit

# Construct the input payload based on the action's requirements
payload = {
    "model": "dev",
    "prompt": "puppy",
    "aspectRatio": "1:1",
    "outputFormat": "webp",
    "guidanceScale": 3.5,
    "mainLoraScale": 1,
    "outputQuality": 80,
    "numberOfOutputs": 1,
    "inferenceStepCount": 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 code snippet, you need to replace YOUR_COGNITIVE_ACTIONS_API_KEY with your actual API key. The action ID for the Fine-Tune FLUX.1-dev with AI Toolkit action is set, and the input payload is structured according to the requirements. The output should display the generated image URLs upon successful execution.

Conclusion

The OSTRIS FLUX.1-dev Cognitive Actions offer developers an accessible way to enhance their applications with advanced image generation capabilities. By leveraging the Fine-Tune FLUX.1-dev action, users can create customized images tailored to various prompts with ease. As you experiment with these actions, consider exploring different input parameters to maximize the potential of your image generation tasks. Happy coding!