Create Stunning Artwork with the afterpeak/flux-slowed Cognitive Actions

In the realm of digital creativity, the afterpeak/flux-slowed API provides developers with powerful Cognitive Actions designed to enhance artistic expression through AI-generated imagery. One such action is the Generate Artwork Style Images, which leverages the Flux LORA model to create visually appealing images styled after artworks tailored for the slowed versions of songs. By utilizing this pre-built action, developers can seamlessly integrate sophisticated image generation capabilities into their applications, enhancing user experiences with unique visual content.
Prerequisites
Before diving into the integration of the Cognitive Actions, ensure you have the following:
- An API key for the Cognitive Actions platform to authenticate your requests.
- Familiarity with making HTTP requests, as you will be sending JSON payloads to the API.
Authentication typically involves passing your API key in the headers of your requests.
Cognitive Actions Overview
Generate Artwork Style Images
The Generate Artwork Style Images action is designed to produce images that embody artistic styles, specifically optimized for audio visualizations related to slowed versions of songs. This action allows for detailed image generation, giving developers the flexibility to customize parameters such as intensity, aspect ratio, and output format.
Input:
The input schema for this action requires the following fields:
- prompt (required): A string that describes the image you want to generate.
- width (optional): An integer specifying the width of the generated image (must be between 256 and 1440).
- height (optional): An integer specifying the height of the generated image (must be between 256 and 1440).
- imageFormat (optional): A string indicating the desired output format (default is
webp). - outputCount (optional): An integer defining how many images to generate (between 1 and 4).
- imageQuality (optional): An integer that sets the quality level for the output images (0 to 100).
- inferenceModel (optional): A string to choose the inference model (
devorschnell). - inferenceSteps (optional): An integer specifying the number of denoising steps (1 to 50).
- promptInfluence (optional): A float that determines how much the prompt influences the image (0 to 1).
- imageAspectRatio (optional): A string specifying the aspect ratio of the image.
- Additional parameters for customization include
mainLoraIntensity,diffusionGuidanceScale, andadditionalLoraIntensity.
Example Input:
{
"width": 1024,
"height": 1024,
"prompt": "SLOW3D. A woman posing for a photo. She is smiling wearing beautiful makeup with a black top. There is a white wall in the background.",
"imageFormat": "webp",
"outputCount": 1,
"imageQuality": 80,
"inferenceModel": "dev",
"inferenceSteps": 28,
"promptInfluence": 0.8,
"imageAspectRatio": "1:1",
"mainLoraIntensity": 0.8,
"diffusionGuidanceScale": 3.5,
"additionalLoraIntensity": 0.8
}
Output:
Upon executing this action, the API returns a URL to the generated image. Here’s an example of a possible output:
[
"https://assets.cognitiveactions.com/invocations/14a0304a-347e-4271-89a5-3ecdcbcad5ed/d999dff5-01e5-4574-ab9e-5f1d2a93b3b9.webp"
]
Conceptual Usage Example (Python):
Here’s how you might structure a call to the Generate Artwork Style Images action using Python. This example highlights how to set up the input payload:
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 = "05fe6acf-4512-4d40-8444-168f8ec6a84f" # Action ID for Generate Artwork Style Images
# Construct the input payload based on the action's requirements
payload = {
"width": 1024,
"height": 1024,
"prompt": "SLOW3D. A woman posing for a photo. She is smiling wearing beautiful makeup with a black top. There is a white wall in the background.",
"imageFormat": "webp",
"outputCount": 1,
"imageQuality": 80,
"inferenceModel": "dev",
"inferenceSteps": 28,
"promptInfluence": 0.8,
"imageAspectRatio": "1:1",
"mainLoraIntensity": 0.8,
"diffusionGuidanceScale": 3.5,
"additionalLoraIntensity": 0.8
}
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 snippet, replace YOUR_COGNITIVE_ACTIONS_API_KEY with your actual API key. The payload is structured according to the requirements specified in the action's input schema, which will be sent to the API to generate an image.
Conclusion
The afterpeak/flux-slowed Cognitive Actions, particularly the Generate Artwork Style Images action, open up a world of creative possibilities for developers looking to integrate AI-driven artwork generation into their applications. By leveraging the capabilities of this action, you can enrich user experiences, create stunning visuals, and explore innovative artistic styles. As a next step, consider experimenting with the various input parameters to tailor the generated images to match your project's unique aesthetic needs. Happy coding!