Create Stunning Images with the catti3/aventus Cognitive Actions

In the realm of image generation, the catti3/aventus API offers powerful Cognitive Actions that enable developers to create custom images based on text prompts. These pre-built actions simplify the process of generating high-quality, styled images with various configurations, making it easier to integrate advanced image generation capabilities into your applications. Whether you're looking to produce artwork, marketing materials, or unique product visuals, these actions provide the tools you need to enhance your digital content seamlessly.
Prerequisites
Before diving into the functionality of the Cognitive Actions, ensure you have the following prerequisites in place:
- API Key: Access to the Cognitive Actions platform requires a valid API key. This key must be included in the request headers to authenticate your API calls.
- Basic Understanding of JSON: Familiarity with JSON format will help you construct requests and handle responses effectively.
In practice, authentication may involve passing the API key in the request headers, as shown in the examples below.
Cognitive Actions Overview
Generate Custom Styled Image
The Generate Custom Styled Image action allows you to create a custom image using detailed text prompts. You can enhance the image through optional inpainting, adjust settings for output quality, format, and aspect ratio, and control various parameters to optimize the generation process.
Input
The input schema for this action includes several properties, with the prompt being a required field:
- prompt (string): The description for the image you want to generate. Including specific terms can help activate trained models effectively.
- mask (string, optional): An image mask for inpainting, which overrides width and height settings.
- seed (integer, optional): A random seed for reproducibility.
- image (string, optional): An input image for transformation or inpainting.
- model (string, optional): Choose between
dev(default) orschnellfor different inference performance. - aspectRatio (string, optional): Select from predefined aspect ratios or set a custom one.
- width (integer, optional): Specify the width if using a custom aspect ratio.
- height (integer, optional): Specify the height if using a custom aspect ratio.
- fastMode (boolean, optional): Enables quicker predictions at the expense of some quality.
- imageFormat (string, optional): Choose between
webp,jpg, orpngfor output format. - outputCount (integer, optional): Number of images to generate (default is 1).
- imageQuality (integer, optional): Set the quality level from 0 to 100 for the generated images.
- inferenceSteps (integer, optional): Number of steps in the denoising process, affecting detail and processing time.
Example Input:
{
"model": "dev",
"prompt": "A luxurious 75ml Aventus perfume bottle, approximately 15cm tall, the cap it white with a gold detail on he top. with a white embossed texture under the golden reflective label on the bottle reads \"Aventus for her\". Around the perfume is a beautiful background fitting of a luxury perfume",
"fastMode": false,
"aspectRatio": "1:1",
"imageFormat": "jpg",
"outputCount": 1,
"imageQuality": 80,
"guidanceScale": 3,
"extraLoraScale": 1,
"inferenceSteps": 28,
"promptStrength": 0.8,
"imageMegapixels": "1",
"loraEffectScale": 1
}
Output
The output of this action typically includes a URL link to the generated image.
Example Output:
[
"https://assets.cognitiveactions.com/invocations/0026ba52-8aef-4a9a-a3fc-1aff90d824c0/2fc46294-8cd7-4ef2-a0da-47dba50f8b6f.jpg"
]
Conceptual Usage Example (Python)
Here's how you might call the Generate Custom Styled Image 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 = "3cd29043-2b7a-4e56-abd7-a2ca90285e68" # Action ID for Generate Custom Styled Image
# Construct the input payload based on the action's requirements
payload = {
"model": "dev",
"prompt": "A luxurious 75ml Aventus perfume bottle, approximately 15cm tall, the cap it white with a gold detail on he top. with a white embossed texture under the golden reflective label on the bottle reads \"Aventus for her\". Around the perfume is a beautiful background fitting of a luxury perfume",
"fastMode": False,
"aspectRatio": "1:1",
"imageFormat": "jpg",
"outputCount": 1,
"imageQuality": 80,
"guidanceScale": 3,
"extraLoraScale": 1,
"inferenceSteps": 28,
"promptStrength": 0.8,
"imageMegapixels": "1",
"loraEffectScale": 1
}
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 code constructs the input payload based on the requirements for generating a custom styled image. The output will be a JSON object containing the URL of the generated image.
Conclusion
The catti3/aventus Cognitive Action for generating custom styled images provides developers with a robust solution for creating visually appealing content through text prompts. By leveraging the flexibility of the input parameters, you can tailor the output to meet your specific needs. Experiment with different prompts and settings to unlock the full potential of this action in your applications. Happy coding!