Generate Stunning Images with the fofr/sd3-with-chaos Cognitive Actions

In today's digital landscape, the ability to generate high-quality images programmatically can significantly enhance applications ranging from art creation to media and marketing. The fofr/sd3-with-chaos specification offers a powerful set of Cognitive Actions that leverage the Stable Diffusion 3 model. This allows developers to produce a variety of images with customizable parameters, creating unique outputs that cater to specific needs.
Prerequisites
Before diving into the Cognitive Actions, ensure you have the following:
- An API key for accessing the Cognitive Actions platform. This key will be used for authentication when making requests.
- Familiarity with JSON format, as inputs and outputs will be structured this way.
For authentication, you will typically pass the API key in the request headers when invoking any of the actions.
Cognitive Actions Overview
Generate Images with Stable Diffusion 3
Description:
This action produces multiple images using the Stable Diffusion 3 model, introducing variability in outputs. Users can customize the image generation process with parameters like chaos, weird, prompt, and output format. Note that a Stability AI Self Hosted License is required for commercial use.
Category: Image Generation
Input
The input schema for this action consists of the following fields:
- chaos (integer): Determines the level of randomness in the generated image outputs. Higher values increase variation. Default is 5.
- weird (boolean): When true, produces more unusual and experimental compositions.
- prompt (string): Text input guiding the image generation, describing desired content and style.
- aspectRatio (string): Defines the aspect ratio of the output image with options like "1:1", "16:9", etc.
- outputFormat (string): Specifies the file format of the output images, such as "webp", "jpg", or "png".
- guidanceScale (number): Controls how closely the image adheres to the prompt. Higher values yield outputs that more closely match the prompt.
- outputQuality (integer): Specifies image quality from 0 (lowest) to 100 (highest).
- numberOfImages (integer): Indicates how many images to generate in a single request, ranging from 1 to 10.
Example Input:
{
"chaos": 7,
"weird": false,
"prompt": "A beautiful landscape photo, an old cabin in the foreground, beautiful mountains, stormy light",
"aspectRatio": "3:2",
"outputFormat": "webp",
"guidanceScale": 3.5,
"outputQuality": 90,
"numberOfImages": 3
}
Output
The output of this action consists of an array of URLs pointing to the generated images. Below is an example of the output you might receive:
Example Output:
[
"https://assets.cognitiveactions.com/invocations/5f8ec85d-1b7f-44e1-a91a-09eb9cc2a8ac/4726fb3a-e8d2-44dd-8362-394f175bd516.webp",
"https://assets.cognitiveactions.com/invocations/5f8ec85d-1b7f-44e1-a91a-09eb9cc2a8ac/6639ef6f-bac1-4dba-915d-21dc54e571ba.webp",
"https://assets.cognitiveactions.com/invocations/5f8ec85d-1b7f-44e1-a91a-09eb9cc2a8ac/d6205593-f788-468c-9683-c3e6da3fe5b3.webp"
]
Conceptual Usage Example (Python)
Here’s how you might structure a call to the Cognitive Actions execution endpoint for this specific 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 = "28743a80-c135-4a19-b88c-6927e9b09bb3" # Action ID for Generate Images with Stable Diffusion 3
# Construct the input payload based on the action's requirements
payload = {
"chaos": 7,
"weird": false,
"prompt": "A beautiful landscape photo, an old cabin in the foreground, beautiful mountains, stormy light",
"aspectRatio": "3:2",
"outputFormat": "webp",
"guidanceScale": 3.5,
"outputQuality": 90,
"numberOfImages": 3
}
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 Python code snippet, replace YOUR_COGNITIVE_ACTIONS_API_KEY with your actual API key. The action_id corresponds to the action for image generation. The payload variable is structured according to the input schema, ensuring that the generated images align with your specified parameters.
Conclusion
The fofr/sd3-with-chaos Cognitive Actions empower developers to create captivating images tailored to their specific needs. By utilizing parameters such as chaos and guidance scale, you can generate unique and high-quality images that enhance user engagement and creativity in your applications. Consider exploring these actions further to incorporate them into your next project!