Generate Stunning Images with heywowyou/heywowflux Cognitive Actions

In the world of digital creativity, generating custom images can elevate your applications and projects, making them visually engaging and unique. The heywowyou/heywowflux API provides developers with powerful Cognitive Actions designed for image generation. By leveraging optimized models and customizable parameters, you can create detailed images, whether for art, marketing, or user engagement. This guide will walk you through the Generate Custom Image action, detailing its capabilities and how to effectively integrate it into your applications.
Prerequisites
Before you start using the Cognitive Actions provided by the heywowyou/heywowflux API, ensure you have the following:
- An API key for the heywowyou/heywowflux platform to authenticate your requests.
- Understanding of basic JSON structure and HTTP requests, as you will need to format your input accordingly.
Authentication typically involves passing your API key in the header of your requests.
Cognitive Actions Overview
Generate Custom Image
The Generate Custom Image action enables you to create custom images with a range of parameters such as image masks, dimensions, and LoRA weights. This action falls under the category of image-generation and is optimized for both detailed outputs and speedy generation.
Input
The input schema for the Generate Custom Image action is a JSON object. The required field is prompt, while others are optional. Here’s a breakdown of the input fields:
- prompt: (string, required) Text prompt for the generated image. Example:
"HENRIK_PURIENNE photographs a young woman. Full body shot." - mask: (string, optional) URI for an image mask, applicable in image inpainting mode.
- seed: (integer, optional) Random seed for reproducible image generation.
- image: (string, optional) URI for an input image, used in image-to-image or inpainting modes.
- width: (integer, optional) Width of the generated image, effective if
aspect_ratiois set tocustom. Must be between 256 and 1440. - height: (integer, optional) Height of the generated image, effective if
aspect_ratiois set tocustom. Must be between 256 and 1440. - goFast: (boolean, optional) Enables faster predictions using a model optimized for speed.
- numOutputs: (integer, optional) Number of output images to generate (1 to 4).
- outputFormat: (string, optional) Specifies the output format for images (webp, jpg, png).
- guidanceScale: (number, optional) Guidance scale for the diffusion process (0 to 10).
- outputQuality: (integer, optional) Quality level for output images (0 to 100).
Example Input:
{
"prompt": "HENRIK_PURIENNE photographs a young woman. Full body shot.",
"loraScale": 1,
"numOutputs": 3,
"outputFormat": "png",
"guidanceScale": 1.5,
"outputQuality": 90,
"extraLoraScale": 1,
"inferenceModel": "dev",
"promptStrength": 1,
"imageAspectRatio": "4:5",
"numInferenceSteps": 50
}
Output
The output of the Generate Custom Image action will typically return an array of URLs pointing to the generated images. Here’s an example of what the output may look like:
Example Output:
[
"https://assets.cognitiveactions.com/invocations/97d0c537-cece-4c62-b05a-493b2c68e665/0034f753-096d-4215-ac97-7b93899593c0.png",
"https://assets.cognitiveactions.com/invocations/97d0c537-cece-4c62-b05a-493b2c68e665/26c0325c-91c2-472f-97ca-0493fedc97f9.png",
"https://assets.cognitiveactions.com/invocations/97d0c537-cece-4c62-b05a-493b2c68e665/63b4857d-58d8-4d0c-8ac2-2a173e4ec4fb.png"
]
Conceptual Usage Example (Python)
Here’s how you might use the Generate Custom Image action in a Python script to generate custom images:
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 = "c4697626-ee48-44ce-8d5c-80cb7dab198b" # Action ID for Generate Custom Image
# Construct the input payload based on the action's requirements
payload = {
"prompt": "HENRIK_PURIENNE photographs a young woman. Full body shot.",
"loraScale": 1,
"numOutputs": 3,
"outputFormat": "png",
"guidanceScale": 1.5,
"outputQuality": 90,
"extraLoraScale": 1,
"inferenceModel": "dev",
"promptStrength": 1,
"imageAspectRatio": "4:5",
"numInferenceSteps": 50
}
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 example, you replace the placeholder for your API key and call the action using a structured JSON payload. The action_id corresponds to the Generate Custom Image action. The response will contain the URLs of the generated images.
Conclusion
The heywowyou/heywowflux API's Generate Custom Image action empowers developers to produce stunning images tailored to their needs. By understanding the input schema and leveraging the provided example, you can easily integrate this functionality into your applications, enhancing user experiences through custom visuals. Start experimenting with the various parameters to unlock the full potential of image generation in your projects!