Create Stunning Images with Toshiro AI Cognitive Actions

24 Apr 2025
Create Stunning Images with Toshiro AI Cognitive Actions

In the world of artificial intelligence, image generation has seen remarkable advancements, particularly with the introduction of models that can create visually stunning artwork. The Toshiro AI Cognitive Actions provide a powerful API for generating images inspired by Toshiro with customizable prompts and settings. This integration allows developers to harness sophisticated image generation capabilities without needing to dive deep into the underlying algorithms, making it accessible and efficient for a variety of applications.

Prerequisites

Before you start using the Toshiro AI Cognitive Actions, ensure you have the following:

  • An API key for accessing the Cognitive Actions platform. This key will be required for authentication when making requests.
  • Familiarity with JSON and Python, as these will be utilized for structuring requests and handling responses.

To authenticate, you'll need to include your API key in the request headers, as shown in the usage examples.

Cognitive Actions Overview

Generate Toshiro-Inspired Image

The Generate Toshiro-Inspired Image action enables you to create images using a stable diffusion model, specifically trained on pictures of Toshiro. This action incorporates user-defined prompts and settings, allowing for enhanced customization and precision in image generation.

Input

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

  • seed (integer, optional): A random seed for generating variations. If not specified, a random seed is used.
  • image (string, optional): URI of the starting image for generating variations (also known as 'img2img'). If set, the output dimensions will match this image, ignoring 'width' and 'height' settings.
  • width (integer, default: 512): Width of the output image in pixels. Valid values are multiples of 128, up to a maximum of 1024.
  • height (integer, default: 512): Height of the output image in pixels. Valid values are multiples of 128, up to a maximum of 1024.
  • prompt (string, default: "a photo of a qdg dog"): Descriptive text that guides image generation. Customize this for best results.
  • scheduler (string, default: "DDIM"): The algorithm used for image generation, such as "DDIM" or "K_EULER".
  • guidanceScale (number, default: 7.5): Input for classifier-free guidance during generation, enhancing adherence to the prompt.
  • negativePrompt (string, optional): List aspects to avoid in the generated output image.
  • promptStrength (number, default: 0.8): Influence of the prompt when using an initial image.
  • numberOfOutputs (integer, default: 1): Specifies how many images should be produced (1 to 4).
  • disableSafetyCheck (boolean, default: false): Toggles safety checks for generated content.
  • numberOfInferenceSteps (integer, default: 50): Determines the number of steps for the denoising process.

Example Input:

{
  "width": 512,
  "height": 512,
  "prompt": "Adorably cute qdg dog portrait, artstation winner by Victo Ngai, Kilian Eng and by Jake Parker, vibrant colors, winning-award masterpiece, fantastically gaudy, aesthetic octane render, 8K HD Resolution",
  "scheduler": "DDIM",
  "guidanceScale": 7.5,
  "negativePrompt": "cartoon, blurry, deformed, watermark, dark lighting, image caption, caption, text, cropped, low quality, low resolution, malformed, messy, blurry, watermark",
  "promptStrength": 0.8,
  "numberOfOutputs": 1,
  "numberOfInferenceSteps": 50
}

Output

The output of this action typically returns a list of image URLs that have been generated based on the provided input parameters.

Example Output:

[
  "https://assets.cognitiveactions.com/invocations/80e59633-97e3-470d-8e28-135d83243fa2/82c9e498-4a01-4c8e-82d7-0a4742c52edc.png"
]

Conceptual Usage Example (Python)

Here's a conceptual Python code snippet showing how to call the Toshiro AI Cognitive Actions endpoint for generating an image:

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 = "44944a79-0712-4034-978a-0ab19b937e58"  # Action ID for Generate Toshiro-Inspired Image

# Construct the input payload based on the action's requirements
payload = {
    "width": 512,
    "height": 512,
    "prompt": "Adorably cute qdg dog portrait, artstation winner by Victo Ngai, vibrant colors, winning-award masterpiece",
    "scheduler": "DDIM",
    "guidanceScale": 7.5,
    "negativePrompt": "cartoon, blurry, watermark",
    "promptStrength": 0.8,
    "numberOfOutputs": 1,
    "numberOfInferenceSteps": 50
}

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, the action ID and input payload are structured according to the requirements of the Generate Toshiro-Inspired Image action. The endpoint URL and request structure are illustrative, serving as a guide for developers.

Conclusion

The Toshiro AI Cognitive Actions provide an exciting opportunity for developers to integrate advanced image generation capabilities into their applications. By utilizing the Generate Toshiro-Inspired Image action, you can create unique and customized images with ease. Experiment with different prompts and settings to unleash your creativity and enhance user experiences. Happy coding!