Create Unique Toast Flavor Profiles with the yash-banka/toast Cognitive Actions

22 Apr 2025
Create Unique Toast Flavor Profiles with the yash-banka/toast Cognitive Actions

In the realm of digital art and artificial intelligence, the yash-banka/toast API offers a remarkable set of Cognitive Actions designed for generating unique and creative images. The standout action in this spec, Create Toast Flavor Profiles, allows developers to create one-of-a-kind flavor profiles on digital toast artwork using advanced image generation techniques. By leveraging various parameters, this action enhances the image generation process, making it an ideal choice for developers looking to integrate AI-driven art into their applications.

Prerequisites

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

  • API Key: You will need an API key for accessing the Cognitive Actions platform. This key is typically passed in the headers of your API requests.
  • Basic knowledge of RESTful APIs: Familiarity with making HTTP requests and handling JSON data will be beneficial.

Cognitive Actions Overview

Create Toast Flavor Profiles

The Create Toast Flavor Profiles action generates new and unique flavor profiles on digital toast artwork using a trained model. Users can refine the image generation process by adjusting various parameters such as prompt strength, scheduler type, and image refinement.

Input: The input schema requires a variety of fields, some of which are optional. Here’s a breakdown of the parameters you can use:

  • mask (string, optional): URI of the input mask for inpaint mode.
  • seed (integer, optional): Random seed for generation; leave blank for randomization.
  • image (string, optional): URI of the input image for img2img or inpaint mode.
  • width (integer): Specifies the output image width in pixels (default: 1024).
  • height (integer): Specifies the output image height in pixels (default: 1024).
  • prompt (string): Text prompt guiding image generation (default: "An astronaut riding a rainbow unicorn").
  • refine (string): Style of refinement, options: 'no_refiner', 'expert_ensemble_refiner', 'base_image_refiner' (default: 'no_refiner').
  • scheduler (string): Selects the scheduler from available options (default: 'K_EULER').
  • guidanceScale (number): Coefficient for classifier-free guidance (default: 7.5, range: 1 to 50).
  • applyWatermark (boolean): Applies a watermark to AI-generated images (default: true).
  • negativePrompt (string, optional): Undesired elements to avoid in image generation.
  • promptStrength (number): Strength of the prompt in img2img or inpaint mode (default: 0.8).
  • numberOfOutputs (integer): Number of images to generate (default: 1, range: 1 to 4).
  • highNoiseFraction (number): For 'expert_ensemble_refiner', proportion of noise (default: 0.8).
  • loraAdditiveScale (number): LoRA additive scale for trained models (default: 0.6).
  • disableSafetyChecker (boolean): Allows disabling the safety checker (default: false).
  • numberOfInferenceSteps (integer): Number of denoising steps (default: 50, range: 1 to 500).
  • numberOfRefinementSteps (integer, optional): Number of refinement steps in 'base_image_refiner'.

Example Input:

{
  "width": 1024,
  "height": 1024,
  "prompt": "In the style of YBAM slice of bread with pesto rosso",
  "refine": "no_refiner",
  "scheduler": "K_EULER",
  "guidanceScale": 7.5,
  "applyWatermark": true,
  "promptStrength": 0.8,
  "numberOfOutputs": 1,
  "highNoiseFraction": 0.8,
  "loraAdditiveScale": 0.6,
  "numberOfInferenceSteps": 50
}

Output: The action typically returns a list of generated image URLs. An example of the output would be:

[
  "https://assets.cognitiveactions.com/invocations/3a547492-2f41-4874-b6e2-4ca6b65cd57a/6df257ad-5998-42b5-823b-31c8dd532e19.png"
]

Conceptual Usage Example (Python): Here’s a brief Python code snippet illustrating how to invoke 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 = "8b909a53-8d20-4ab4-9461-6958acc921c3"  # Action ID for Create Toast Flavor Profiles

# Construct the input payload based on the action's requirements
payload = {
    "width": 1024,
    "height": 1024,
    "prompt": "In the style of YBAM slice of bread with pesto rosso",
    "refine": "no_refiner",
    "scheduler": "K_EULER",
    "guidanceScale": 7.5,
    "applyWatermark": true,
    "promptStrength": 0.8,
    "numberOfOutputs": 1,
    "highNoiseFraction": 0.8,
    "loraAdditiveScale": 0.6,
    "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 corresponds to the Create Toast Flavor Profiles action, and the payload is structured according to the input schema. The code handles the API call and prints the results or any errors encountered.

Conclusion

Integrating the Create Toast Flavor Profiles action from the yash-banka/toast API opens up a world of possibilities for developers looking to enhance their applications with unique, AI-generated imagery. By utilizing the various input parameters, you can customize the image output to suit your creative needs. Explore this action further to see how it can elevate your projects and engage your users with delightful digital art!