Generate Stunning Custom Images with ReTyler v2 Cognitive Actions

22 Apr 2025
Generate Stunning Custom Images with ReTyler v2 Cognitive Actions

In the ever-evolving landscape of image generation, the ReTyler v2 Cognitive Actions provide developers with powerful tools to create custom images tailored to specific requirements. These actions enable easy integration of advanced image generation capabilities into applications, allowing for detailed customization of parameters such as image resolution, aspect ratio, and output format. By utilizing the models 'dev' and 'schnell', developers can optimize inference steps for their image generation tasks.

Prerequisites

Before diving into the world of ReTyler Cognitive Actions, ensure you have the following:

  • An API key for the Cognitive Actions platform.
  • Basic understanding of JSON and RESTful API principles.
  • Familiarity with Python for executing API calls.

Authentication typically involves passing your API key in the headers of your requests.

Cognitive Actions Overview

Generate Custom Image with ReTyler

Description:
This action generates a custom image using ReTyler v2.0, allowing for detailed configuration of parameters such as image resolution, aspect ratio, and output format. You can utilize models 'dev' and 'schnell' for optimized inference steps.

Category: image-generation

Input

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

  • prompt (required): A description of the desired image (e.g., "A comic-style image of TYLER riding a sloth").
  • mask (optional): URI of the image mask used for image inpainting mode.
  • seed (optional): An integer for reproducible image generation.
  • image (optional): URI of the input image for image-to-image or inpainting mode.
  • width (optional): Width in pixels of the generated image (256-1440).
  • height (optional): Height in pixels of the generated image (256-1440).
  • imageAspectRatio (optional): Aspect ratio for the image (e.g., "16:9").
  • numberOfOutputs (optional): Number of images to generate (1-4).
  • outputFormat (optional): Format of the output images (e.g., "png", "jpg").
  • inferenceModel (optional): Model for inference ('dev' or 'schnell').

Example Input:

{
  "prompt": "A comic-style image of TYLER riding a sloth"
}

Output

The output will typically return a JSON array containing the URI(s) of the generated image(s).

Example Output:

[
  "https://assets.cognitiveactions.com/invocations/12b8dfdb-b91d-458e-a8ee-8799124097e4/a9b7afb2-0c6a-4a4f-bdcf-0ea16cae814f.webp"
]

Conceptual Usage Example (Python)

Below is a conceptual Python code snippet showing how you might call the ReTyler action to generate a custom image. This demonstrates how to structure the input JSON payload correctly.

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 = "f8db3d7e-f8c9-4ebd-bccd-3528e9cefe67"  # Action ID for Generate Custom Image with ReTyler

# Construct the input payload based on the action's requirements
payload = {
    "prompt": "A comic-style image of TYLER riding a sloth"
}

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 the code above, replace "YOUR_COGNITIVE_ACTIONS_API_KEY" with your actual API key. The action ID and input payload are structured appropriately for the API call. This example serves as a guideline for integrating the action into your application.

Conclusion

The ReTyler v2 Cognitive Actions provide a robust framework for generating customized images, transforming creative ideas into visual representations with ease. By leveraging these actions, developers can enhance their applications with powerful image generation features. Explore the flexibility of the input parameters to tailor the output to your specific needs, whether for artistic projects, content creation, or any innovative use case you can imagine. Happy coding!