Generate Stunning Images with the alexandercgo2/craisee3 Cognitive Action

In the world of artificial intelligence, the ability to generate custom images based on textual descriptions has transformed creative processes across industries. The alexandercgo2/craisee3 spec provides powerful Cognitive Actions that allow developers to harness this capability with ease. Among these actions is the Generate Custom Image action, which enables you to create unique images by specifying various parameters, including prompts, models, and output formats. This article will guide you through the integration of this action into your applications.
Prerequisites
To get started with the Cognitive Actions from the alexandercgo2/craisee3 spec, you'll need:
- An API key for the Cognitive Actions platform to authenticate your requests.
- A basic understanding of JSON structure and how to make HTTP requests.
Authentication typically involves including your API key in the headers of your requests, ensuring secure access to the service.
Cognitive Actions Overview
Generate Custom Image
The Generate Custom Image action allows you to create custom images using text prompts and a range of configurable parameters. This action is classified under the image-generation category and provides flexibility in terms of image quality, resolution, and model selection.
Input
The input schema for this action requires the following fields:
- prompt (required): The text prompt that guides the image generation. Example:
"a collage of future retro car in front of a wall, in the style of CRAISEE". - mask (optional): An image mask for inpainting.
- image (optional): An input image for inpainting mode.
- model (optional): The inference model, either
dev(default) orschnell. - aspectRatio (optional): The aspect ratio of the generated image, with options like
1:1,16:9, orcustom. - outputFormat (optional): The desired output format, such as
webp,jpg, orpng. - guidanceScale (optional): A scale to guide the diffusion process, with typical values around 3.5.
- numberOfOutputs (optional): The number of images to generate, ranging from 1 to 4.
Here’s a practical example of the JSON payload required to invoke this action:
{
"model": "dev",
"prompt": "a collage of future retro car in front of a wall, in the style of CRAISEE",
"aspectRatio": "1:1",
"outputFormat": "webp",
"guidanceScale": 3.5,
"loraIntensity": 1,
"outputQuality": 90,
"promptStrength": 0.8,
"numberOfOutputs": 1,
"inferenceStepsCount": 28,
"additionalLoraIntensity": 1
}
Output
Upon successfully executing the action, you will receive a response containing the URL(s) of the generated image(s). An example output might look like this:
[
"https://assets.cognitiveactions.com/invocations/167fe074-ea32-4412-ba70-9dfbda572104/b6da81ec-899f-4268-a89e-21885502e105.webp"
]
Conceptual Usage Example (Python)
The following Python code snippet demonstrates how to call the Generate Custom Image action using the provided input schema:
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 = "0dcecb2a-3797-42f4-b6b1-6b66f493fa83" # Action ID for Generate Custom Image
# Construct the input payload based on the action's requirements
payload = {
"model": "dev",
"prompt": "a collage of future retro car in front of a wall, in the style of CRAISEE",
"aspectRatio": "1:1",
"outputFormat": "webp",
"guidanceScale": 3.5,
"loraIntensity": 1,
"outputQuality": 90,
"promptStrength": 0.8,
"numberOfOutputs": 1,
"inferenceStepsCount": 28,
"additionalLoraIntensity": 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 code, replace YOUR_COGNITIVE_ACTIONS_API_KEY with your actual API key. The payload variable is structured according to the input requirements of the Generate Custom Image action. The endpoint URL and request structure are hypothetical but illustrate how you would typically structure your request.
Conclusion
The Generate Custom Image action from the alexandercgo2/craisee3 spec provides a robust way for developers to create custom images tailored to their needs. With a variety of parameters to adjust the output, this action can be integrated into applications for artistic, marketing, or functional uses. As you experiment with the capabilities of this action, consider exploring additional use cases and combinations of parameters to maximize your creative potential.