Create Stunning Images with the fofr/flux-hyundai-n-vision-74 Cognitive Actions

22 Apr 2025
Create Stunning Images with the fofr/flux-hyundai-n-vision-74 Cognitive Actions

The fofr/flux-hyundai-n-vision-74 Cognitive Actions offer developers a powerful way to generate high-quality images using advanced models like Flux Lora. These pre-built actions simplify the process of image creation, allowing you to focus on your application's unique features while leveraging sophisticated image generation capabilities.

Prerequisites

Before you dive into using the Cognitive Actions, ensure you have:

  • An API key for the Cognitive Actions platform.
  • Familiarity with JSON payloads and basic API interaction.

For authentication, you will typically pass your API key in the headers of your requests.

Cognitive Actions Overview

Generate Image with Flux Lora

The Generate Image with Flux Lora action creates an image based on a specific text prompt. This action employs the Flux Lora model to optimize image generation through various adjustable parameters, ensuring high-quality output tailored to your needs.

Input

The input schema for this action requires the following fields:

  • prompt (required): A text string that describes the image you want to generate. For example, "Hyundai N Vision 74 car."

Optional parameters include:

  • mask: An image mask for inpainting mode (URI format).
  • seed: An integer for reproducible image generation.
  • image: An input image for image-to-image or inpainting mode (URI format).
  • model: Select either "dev" or "schnell" (default is "dev").
  • width: The width of the image (when using a custom aspect ratio).
  • height: The height of the image (when using a custom aspect ratio).
  • loraScale: A number to adjust the intensity of the LoRA application (default is 1).
  • numOutputs: Number of images to generate (default is 1).
  • aspectRatio: Determines the aspect ratio of the image (default is "1:1").
  • imageFormat: Output file format (default is "webp").
  • imageQuality: Quality level of the output image (default is 80).
  • guidanceScale: Influences the diffusion process (default is 3).
  • enableFastMode: Allows faster prediction mode (default is false).
  • numInferenceSteps: Number of denoising steps (default is 28).

Here’s an example of a valid JSON payload:

{
  "model": "dev",
  "prompt": "Hyundai N Vision 74 car",
  "loraScale": 1,
  "numOutputs": 1,
  "aspectRatio": "3:2",
  "imageFormat": "webp",
  "imageQuality": 80,
  "guidanceScale": 3.5,
  "extraLoraScale": 0.8,
  "numInferenceSteps": 28
}

Output

Upon successful execution, the action returns a URL linking to the generated image. For example:

[
  "https://assets.cognitiveactions.com/invocations/70fb6047-30e0-4ece-8118-986553ddfd15/aed7a4f5-b80c-46d0-9776-aa6e42aefdde.webp"
]

Conceptual Usage Example (Python)

Here’s how you might call the Generate Image with Flux Lora 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 = "665353cb-b439-4632-8bd5-8ba53a423"  # Action ID for Generate Image with Flux Lora

# Construct the input payload based on the action's requirements
payload = {
    "model": "dev",
    "prompt": "Hyundai N Vision 74 car",
    "loraScale": 1,
    "numOutputs": 1,
    "aspectRatio": "3:2",
    "imageFormat": "webp",
    "imageQuality": 80,
    "guidanceScale": 3.5,
    "extraLoraScale": 0.8,
    "numInferenceSteps": 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}")

This code snippet demonstrates how to structure the input payload and send a request to the hypothetical Cognitive Actions execution endpoint. Replace YOUR_COGNITIVE_ACTIONS_API_KEY with your actual API key.

Conclusion

The Generate Image with Flux Lora action provides a straightforward way to create stunning images tailored to your specifications. With adjustable parameters and high-quality output, developers can easily integrate this capability into their applications. Explore additional use cases and experiment with various settings to fully leverage the potential of the fofr/flux-hyundai-n-vision-74 Cognitive Actions in your projects!