Create Stunning Images with the prunaai/sdxl-cheetah Cognitive Actions

22 Apr 2025
Create Stunning Images with the prunaai/sdxl-cheetah Cognitive Actions

The prunaai/sdxl-cheetah API offers developers a powerful toolset for generating images based on textual prompts. By utilizing the Cognitive Actions provided, you can easily integrate image generation capabilities into your applications. This post will guide you through the key Cognitive Action available in the prunaai/sdxl-cheetah spec, detailing its features, input requirements, and practical usage.

Prerequisites

Before integrating the Cognitive Actions, ensure you have the following:

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

Authentication typically involves passing your API key in the request headers.

Cognitive Actions Overview

Generate Images Using SDXL Cheetah

The Generate Images Using SDXL Cheetah action allows you to create images from a specified textual prompt. This action is highly customizable, enabling you to adjust image dimensions, guidance scale, inference steps, and even optimize for speed.

Input

The input for this action is structured as follows:

  • prompt (required): A textual input that guides the generation process.
  • seed (optional): An integer for initializing the random number generator (default: 42).
  • imageWidth (optional): The width of the generated image in pixels (default: 1024).
  • imageHeight (optional): The height of the generated image in pixels (default: 1024).
  • guidanceScale (optional): A floating-point value controlling the adherence to the prompt (default: 7.5).
  • numberOfImages (optional): The number of images to generate (default: 1).
  • numberOfInferenceSteps (optional): The number of steps in the inference process (default: 50).
  • enableMaxSpeedOptimization (optional): A flag for speed optimization, which may affect quality (default: false).

Example Input:

{
  "seed": 0,
  "prompt": "a beautiful unicorn",
  "imageWidth": 1024,
  "imageHeight": 1024,
  "guidanceScale": 7.5,
  "numberOfImages": 1,
  "numberOfInferenceSteps": 30,
  "enableMaxSpeedOptimization": false
}

Output

The output of this action typically returns a URL linking to the generated image. For example:

"https://assets.cognitiveactions.com/invocations/805fa05f-1b95-418e-b924-b0368af1fed8/fa1b6a2b-cff9-4a2c-bca3-3f9d32840fb9.png"

Conceptual Usage Example (Python)

Here’s a conceptual example of how you might call this 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 = "19093215-a9c3-45c0-b05b-02fb28ba02c5"  # Action ID for Generate Images Using SDXL Cheetah

# Construct the input payload based on the action's requirements
payload = {
    "seed": 0,
    "prompt": "a beautiful unicorn",
    "imageWidth": 1024,
    "imageHeight": 1024,
    "guidanceScale": 7.5,
    "numberOfImages": 1,
    "numberOfInferenceSteps": 30,
    "enableMaxSpeedOptimization": False
}

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:

  • Replace YOUR_COGNITIVE_ACTIONS_API_KEY with your actual API key.
  • The action_id corresponds to the Generate Images action.
  • The payload is structured based on the input schema described above.

Conclusion

The prunaai/sdxl-cheetah Cognitive Actions provide a robust framework for generating images from textual prompts. By leveraging these capabilities, developers can enhance their applications with stunning visual content tailored to user input. Explore further by experimenting with different prompts and configurations to see what unique images you can create!