Create Stunning Images with Cafe Chileno's AI Actions

Cognitive Actions from Cafe Chileno allow developers to harness the power of AI-driven image generation. With the ability to create visually striking images tailored to specific prompts, these actions simplify the creative process, enabling rapid content creation that meets diverse needs. Whether you're developing marketing materials, visual storytelling, or enhancing user experiences in applications, the possibilities are endless.
Imagine generating high-quality images that fit your precise specifications—this is where Cafe Chileno’s image generation capabilities shine. From customizing aspect ratios to adjusting output formats, you'll have the control needed to produce images that truly resonate with your audience.
Prerequisites
To get started, you will need a valid Cognitive Actions API key and a basic understanding of making API calls.
Generate Image with Prediction Models
The "Generate Image with Prediction Models" action allows developers to create images using sophisticated AI models—namely 'dev' and 'schnell'. This action provides extensive customization options, including inpainting capabilities, aspect ratio adjustments, and output format selections. It solves the problem of time-consuming manual image creation while delivering high-quality, realistic visuals.
Input Requirements: The action requires a prompt to guide the image generation process. Additional parameters such as aspect ratio, dimensions (height and width), output format, and model choice can be specified to tailor the output. You can also include a mask for inpainting or an image for image-to-image generation.
Expected Output: The output will be a set of generated images based on the input criteria, which can be delivered in formats like webp, jpg, or png. The action can return multiple outputs, giving you a variety of options to choose from.
Use Cases for this specific action:
- Marketing and Advertising: Create enticing visuals for product promotions, such as coffee packaging, that capture attention and showcase quality.
- Content Creation: Generate images for blogs, social media posts, or websites that align with specific themes or narratives.
- Personal Projects: Bring your creative visions to life by generating custom artwork or illustrations based on unique prompts.
import requests
import json
# Replace with your actual Cognitive Actions API key and endpoint
# Ensure your environment securely handles the API key
COGNITIVE_ACTIONS_API_KEY = "YOUR_COGNITIVE_ACTIONS_API_KEY"
# This endpoint URL is hypothetical and should be documented for users
COGNITIVE_ACTIONS_EXECUTE_URL = "https://api.cognitiveactions.com/actions/execute"
action_id = "98932f92-6e28-4439-9932-474a7482edea" # Action ID for: Generate Image with Prediction Models
# Construct the exact input payload based on the action's requirements
# This example uses the predefined example_input for this action:
payload = {
"model": "dev",
"prompt": "Advertising photograph of a 200 gram jar of premium instant coffee, CAFECLP, in a glass container with gold lid and black and gold label. The elegant design should emphasize its origin of finely ground and roasted Arabica beans, with a focus on standing out its 'Intense Flavor & Aroma'. The image must convey luxury and quality, with soft and elegant lighting that highlights the gold and black details of the packaging, generating a warm and cozy atmosphere. Suggested backgrounds: natural textures such as wood or dark granite, accompanied. of coffee-related accessories to create a sophisticated and tempting atmosphere.",
"loraScale": 1,
"numOutputs": 4,
"aspectRatio": "3:4",
"outputFormat": "png",
"guidanceScale": 3.5,
"outputQuality": 100,
"extraLoraScale": 1,
"promptStrength": 0.8,
"numInferenceSteps": 28
}
headers = {
"Authorization": f"Bearer {COGNITIVE_ACTIONS_API_KEY}",
"Content-Type": "application/json",
# Add any other required headers for the Cognitive Actions API
}
# Prepare the request body for the hypothetical execution endpoint
request_body = {
"action_id": action_id,
"inputs": payload
}
print(f"--- Calling Cognitive Action: {action.name or action_id} ---")
print(f"Endpoint: {COGNITIVE_ACTIONS_EXECUTE_URL}")
print(f"Action ID: {action_id}")
print("Payload being sent:")
print(json.dumps(request_body, indent=2))
print("------------------------------------------------")
try:
response = requests.post(
COGNITIVE_ACTIONS_EXECUTE_URL,
headers=headers,
json=request_body
)
response.raise_for_status() # Raise an exception for bad status codes (4xx or 5xx)
result = response.json()
print("Action executed successfully. Result:")
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 (non-JSON): {e.response.text}")
print("------------------------------------------------")
Conclusion
Cafe Chileno's Cognitive Actions empower developers to effortlessly generate stunning images tailored to their specific needs, saving time and enhancing creativity. With customizable options and the ability to produce high-quality outputs, these actions are perfect for various applications, from marketing to personal projects.
Ready to transform your image generation process? Start integrating Cafe Chileno's AI Actions today and unlock a world of creative possibilities!