Enhance Your Applications with Image Generation: Using Flux Dev's Tatra T3 Cognitive Actions

22 Apr 2025
Enhance Your Applications with Image Generation: Using Flux Dev's Tatra T3 Cognitive Actions

In the ever-evolving landscape of application development, integrating advanced features like image generation can significantly enhance user experience. The rinatkurmaev/flux-dev-lora-tatra-t3 API provides a powerful Cognitive Action for generating high-quality images of the iconic Tatra T3 tram. This article explores how to utilize this action, highlighting its capabilities, input requirements, and output results, so you can seamlessly integrate it into your applications.

Prerequisites

Before diving into the integration process, ensure you have the following:

  • An API key for the Cognitive Actions platform.
  • Familiarity with making HTTP requests and handling JSON payloads.

Conceptually, authentication typically involves passing your API key in the request headers to authenticate your access to the Cognitive Actions.

Cognitive Actions Overview

Generate Tatra T3 Tram Photos

This operation generates high-quality images of the Tatra T3 tram, leveraging a LoRA model. Users can customize various image properties, such as resolution, aspect ratio, and output format, while also having options for faster generation and specific styles through prompts.

Input

The input for this action consists of several fields, with prompt being the only required one. Below is the schema for the input:

{
  "prompt": "A tram TATRAT3 running a street in Florida. A vintage photo. 60s",
  "model": "dev",
  "width": 1024,
  "goFast": true,
  "height": 1024,
  "outputCount": 1,
  "imageQuality": 80,
  "mainLoraScale": 1,
  "denoisingSteps": 28,
  "imageResolution": "1",
  "imageAspectRatio": "1:1",
  "imageOutputFormat": "png",
  "imageGuidanceScale": 3,
  "additionalWeightScale": 1,
  "initialPromptStrength": 0.8
}
  • Required Field:
    • prompt: String that describes the image you want to generate.
  • Optional Fields:
    • model: Choose between "dev" or "schnell".
    • width: Set the width of the image (should be multiple of 16).
    • height: Set the height of the image (should be multiple of 16).
    • goFast: Toggle for faster predictions.
    • outputCount: Number of images to generate (1 to 4).
    • imageQuality: Quality of the output image (0 to 100).
    • mainLoraScale: Intensity of the main LoRA application.
    • denoisingSteps: Steps for image generation (1 to 50).
    • imageResolution: Approximate megapixels.
    • imageAspectRatio: Aspect ratio of the image.
    • imageOutputFormat: Format of the output image (webp, jpg, png).
    • imageGuidanceScale: Guidance scale for image realism.
    • additionalWeightScale: Extra LoRA application intensity.
    • initialPromptStrength: Strength of the prompt during image generation.

Example Input

Here’s an example of how the input JSON payload might look:

{
  "model": "dev",
  "width": 1024,
  "goFast": true,
  "height": 1024,
  "prompt": "A tram TATRAT3 running a street in Florida. A vintage photo. 60s",
  "outputCount": 1,
  "imageQuality": 80,
  "mainLoraScale": 1,
  "denoisingSteps": 28,
  "imageResolution": "1",
  "imageAspectRatio": "1:1",
  "imageOutputFormat": "png",
  "imageGuidanceScale": 3,
  "additionalWeightScale": 1,
  "initialPromptStrength": 0.8
}

Output

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

[
  "https://assets.cognitiveactions.com/invocations/36339a52-af99-4179-afe6-46efb17e14d2/17718113-226d-41e0-8e6e-da57f69e04e7.png"
]

This URL can be directly used to access the generated image.

Conceptual Usage Example (Python)

Here’s a conceptual Python code snippet to demonstrate how to call this action:

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 = "89037dcb-dcfe-47b8-8b31-cb10d2cfc2d5"  # Action ID for Generate Tatra T3 Tram Photos

# Construct the input payload based on the action's requirements
payload = {
    "model": "dev",
    "width": 1024,
    "goFast": True,
    "height": 1024,
    "prompt": "A tram TATRAT3 running a street in Florida. A vintage photo. 60s",
    "outputCount": 1,
    "imageQuality": 80,
    "mainLoraScale": 1,
    "denoisingSteps": 28,
    "imageResolution": "1",
    "imageAspectRatio": "1:1",
    "imageOutputFormat": "png",
    "imageGuidanceScale": 3,
    "additionalWeightScale": 1,
    "initialPromptStrength": 0.8
}

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 example, we specify the action ID and input payload, then make a POST request to the hypothetical endpoint. The output will display the URL of the generated image.

Conclusion

The Generate Tatra T3 Tram Photos action offers developers a robust tool for integrating high-quality image generation into their applications. By leveraging customizable parameters, you can tailor the output to meet specific needs, enhancing the visual appeal of your projects. Consider experimenting with different prompts and configurations to explore the full potential of this action in your applications!