Generate Stunning Images with the kayaeh/eli_flux Cognitive Actions

In the realm of AI-driven creativity, the kayaeh/eli_flux API provides a powerful set of Cognitive Actions designed to simplify the image generation process. Among these actions, one stands out for its versatility: Generate Image with Inpainting. This action allows developers to create high-quality images based on textual prompts while incorporating advanced features like inpainting, customizable aspect ratios, and fine-tuning options. With these pre-built actions, developers can focus on their unique applications without delving into the complexities of image generation algorithms.
Prerequisites
Before diving into the usage of the Cognitive Actions, ensure you have the following prerequisites:
- An API key for the Cognitive Actions platform to authenticate your requests.
- Basic knowledge of JSON and HTTP requests.
- Familiarity with Python is beneficial for utilizing the provided usage examples.
To authenticate your requests, you will typically pass your API key in the headers of your HTTP requests.
Cognitive Actions Overview
Generate Image with Inpainting
Description: This action generates images using specified models while offering options for image inpainting, custom aspect ratios, and various quality settings. It allows for advanced manipulation through adjustable parameters, ensuring flexibility in achieving desired outputs.
- Category: Image Generation
Input
The required input for this action is structured as follows:
prompt(string, required): The textual description that guides the image generation. Including specific trigger words can enhance the outcome.model(string, optional): Specifies the model for inference. Options includedev(optimal for 28 steps) orschnell(optimized for 4 steps).aspectRatio(string, optional): Sets the aspect ratio for the generated image. Choosingcustomallows for width and height specifications.width(integer, optional): Width of the generated image (if aspect ratio is custom).height(integer, optional): Height of the generated image (if aspect ratio is custom).- Other parameters: Include
seed,guidanceScale,outputQuality,numberOfOutputs, and several others that fine-tune the generation process.
Example Input:
{
"model": "dev",
"prompt": "ELI stands confidently with two majestic dragons by her side, their scales shimmering in the sunlight. Her platinum hair flows in the wind as she wears a medieval-style armor adorned with silver accents. Her fierce expression shows both strength and compassion as she gazes into the distance. The dragons, with large, leathery wings, curl protectively around her. The background shows a craggy mountain range with a dramatic sky filled with swirling clouds, setting a powerful fantasy scene.",
"loraScale": 1,
"aspectRatio": "1:1",
"outputFormat": "webp",
"guidanceScale": 3.5,
"outputQuality": 90,
"extraLoraScale": 1,
"promptStrength": 0.8,
"numberOfOutputs": 1,
"numberOfInferenceSteps": 28
}
Output
Upon successful execution, this action returns a URL pointing to the generated image.
Example Output:
[
"https://assets.cognitiveactions.com/invocations/816f5887-81c7-47bf-971f-0404c2bfb428/511d93c3-e0dc-4d4d-bc38-c0d1b850a168.webp"
]
Conceptual Usage Example (Python)
Here’s how you might call the Generate Image with Inpainting 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 = "3cfdff6b-b91a-40d3-a079-4f66da025032" # Action ID for Generate Image with Inpainting
# Construct the input payload based on the action's requirements
payload = {
"model": "dev",
"prompt": "ELI stands confidently with two majestic dragons by her side...",
"loraScale": 1,
"aspectRatio": "1:1",
"outputFormat": "webp",
"guidanceScale": 3.5,
"outputQuality": 90,
"extraLoraScale": 1,
"promptStrength": 0.8,
"numberOfOutputs": 1,
"numberOfInferenceSteps": 28
}
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 snippet, you will replace the API key and endpoint with the appropriate values. The payload contains the necessary parameters for generating the image. The response will yield a URL to the generated image.
Conclusion
The kayaeh/eli_flux Cognitive Actions offer developers a robust toolset for generating stunning images with remarkable flexibility. By leveraging the Generate Image with Inpainting action, you can create unique visuals that match your creative vision with ease. Whether you're building applications that require dynamic image generation or simply exploring the capabilities of AI in art, these actions provide a straightforward approach to achieving high-quality results. Start integrating these actions today and unlock new possibilities in your projects!