Generate Stunning Images with Cognitive Actions for applyish/somto_td_flux_2

21 Apr 2025
Generate Stunning Images with Cognitive Actions for applyish/somto_td_flux_2

In today’s digital landscape, the ability to generate high-quality images programmatically can set your applications apart. The applyish/somto_td_flux_2 spec provides powerful Cognitive Actions that allow developers to create stunning visuals using customizable parameters. By leveraging these pre-built actions, you can save significant development time while ensuring high-quality outputs tailored to your needs.

Prerequisites

Before you start integrating the Cognitive Actions, make sure you have the following:

  • An API key for accessing the Cognitive Actions platform.
  • Familiarity with JSON structures, as you will be working with JSON payloads to send requests.
  • Basic knowledge of handling HTTP requests in your preferred programming language.

Authentication typically involves passing your API key in the headers of your requests to access the Cognitive Actions.

Cognitive Actions Overview

Generate Image Using LoRA Model

The Generate Image Using LoRA Model action is designed to create high-quality images based on textual prompts. This action empowers developers to customize aspects such as image dimensions, output formats, and the overall quality of the generated images.

Input

The input for this action requires the following fields:

  • prompt (required): A detailed textual description for image generation.
  • image (optional): URI of an input image for inpainting or image-to-image generation.
  • goFast (optional): A boolean flag to enable or disable fast generation mode.
  • width (optional): The width of the generated image (if aspect_ratio is set to custom).
  • height (optional): The height of the generated image (if aspect_ratio is set to custom).
  • numOutputs (optional): The number of images to generate.
  • guidanceScale (optional): A value affecting the diffusion process for realism.
  • outputQuality (optional): Quality level for the output image.
  • inferenceModel (optional): The model used for inference, either "dev" or "schnell".
  • imageAspectRatio (optional): Aspect ratio of the generated image.
  • imageOutputFormat (optional): Format for the output images.

Example Input:

{
  "image": "https://replicate.delivery/pbxt/MA2CyywxzoJNbEHQkAclmQUVmvl0VWKI0Rta2CQSsarMQDtz/out-2%20%284%29.webp",
  "goFast": false,
  "prompt": "in the style of somto_td, Roronoa Zoro , standing confidently in a battle-ready pose, holding two katanas, fighting pose, Mackenyu Maeda, battle scene background, anger in his eyes, clear face , 4k, quality, clear facial features, green hair , ear rings",
  "loraScale": 1,
  "numOutputs": 4,
  "guidanceScale": 3,
  "outputQuality": 80,
  "inferenceModel": "dev",
  "imageAspectRatio": "9:16",
  "imageOutputFormat": "webp",
  "numInferenceSteps": 28
}

Output

The action typically returns an array of image URLs, each pointing to a newly generated image based on the provided prompt and parameters.

Example Output:

[
  "https://assets.cognitiveactions.com/invocations/bfb83f72-08d0-4010-b38c-9736649a419a/ede90dcd-6cff-4929-9e52-0428d5e00591.webp",
  "https://assets.cognitiveactions.com/invocations/bfb83f72-08d0-4010-b38c-9736649a419a/f7937cf1-f813-419b-a420-595d90373faf.webp",
  "https://assets.cognitiveactions.com/invocations/bfb83f72-08d0-4010-b38c-9736649a419a/e64db69f-628c-4de5-885a-2a5ff075b289.webp",
  "https://assets.cognitiveactions.com/invocations/bfb83f72-08d0-4010-b38c-9736649a419a/584cf661-f2a3-4dd5-9f0d-6288438a3aa9.webp"
]

Conceptual Usage Example (Python)

Below is a conceptual Python code snippet to illustrate how a developer might call the Cognitive Actions endpoint to generate images:

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 = "b5b331b3-2940-4b78-b192-a00c9cd18671" # Action ID for Generate Image Using LoRA Model

# Construct the input payload based on the action's requirements
payload = {
    "image": "https://replicate.delivery/pbxt/MA2CyywxzoJNbEHQkAclmQUVmvl0VWKI0Rta2CQSsarMQDtz/out-2%20%284%29.webp",
    "goFast": False,
    "prompt": "in the style of somto_td, Roronoa Zoro , standing confidently in a battle-ready pose, holding two katanas, fighting pose, Mackenyu Maeda, battle scene background, anger in his eyes, clear face , 4k, quality, clear facial features, green hair , ear rings",
    "loraScale": 1,
    "numOutputs": 4,
    "guidanceScale": 3,
    "outputQuality": 80,
    "inferenceModel": "dev",
    "imageAspectRatio": "9:16",
    "imageOutputFormat": "webp",
    "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}")

In this snippet, you will see how the action ID and input payload are structured correctly to call the cognitive actions endpoint. The endpoint URL and request structure are illustrative and should be adapted to your actual implementation.

Conclusion

The applyish/somto_td_flux_2 Cognitive Actions offer a robust solution for generating high-quality images tailored to your specifications. By utilizing these actions, you can enhance your applications with visually appealing content, streamline your development process, and provide your users with unique experiences. As a next step, consider experimenting with different input parameters to discover the full potential of the image generation capabilities. Happy coding!