Create Stunning Custom Images with brinnaebent/blue-devil Cognitive Actions

In the realm of image generation, the brinnaebent/blue-devil API offers powerful Cognitive Actions that enable developers to create custom images with refinement options, inpainting, and guidance. These pre-built actions simplify the integration of advanced image generation capabilities into your applications, allowing for creative flexibility and enhanced user experiences.
Prerequisites
Before you start using the Cognitive Actions from the brinnaebent/blue-devil API, ensure you have the following:
- An API key for the Cognitive Actions platform. This key will be used to authenticate your requests.
- Basic knowledge of JSON format, as the requests and responses will utilize this structure.
Authentication typically involves passing your API key in the headers of your requests.
Cognitive Actions Overview
Generate Custom Images with Refinement
Description: Generate custom images using a variety of styles with options for refinement, inpainting, and guidance.
Category: Image Generation
Input: The action requires a structured input defined by the schema below, along with an example input:
{
"width": 1024,
"height": 1024,
"prompt": "a photo of a TOK mascot on a cruise ship",
"refine": "no_refiner",
"loraScale": 0.6,
"scheduler": "K_EULER",
"guidanceScale": 10,
"applyWatermark": true,
"negativePrompt": "",
"promptStrength": 0.8,
"numberOfOutputs": 1,
"highNoiseFraction": 0.8,
"numberOfInferenceSteps": 100
}
Output: Upon successful execution, the action returns an array containing the URL of the generated image:
[
"https://assets.cognitiveactions.com/invocations/888468dd-86dd-4efd-81e7-3e629314ab28/bb16a64a-54ad-461f-b026-d8db9410a386.png"
]
Conceptual Usage Example (Python)
Here’s how you can call the Generate Custom Images with Refinement 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 = "25178afd-47a1-4f06-8e7e-1be2513c887c" # Action ID for Generate Custom Images with Refinement
# Construct the input payload based on the action's requirements
payload = {
"width": 1024,
"height": 1024,
"prompt": "a photo of a TOK mascot on a cruise ship",
"refine": "no_refiner",
"loraScale": 0.6,
"scheduler": "K_EULER",
"guidanceScale": 10,
"applyWatermark": True,
"negativePrompt": "",
"promptStrength": 0.8,
"numberOfOutputs": 1,
"highNoiseFraction": 0.8,
"numberOfInferenceSteps": 100
}
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:
- Replace
YOUR_COGNITIVE_ACTIONS_API_KEYwith your actual API key. - The
action_idis set to the identifier for the action you want to execute. - The
payloadJSON object is constructed based on the required fields for generating custom images.
Conclusion
The brinnaebent/blue-devil Cognitive Actions offer powerful capabilities for custom image generation, providing developers with the tools to create unique visuals tailored to specific needs. Implementing these actions can enhance your applications by allowing users to generate content dynamically. Explore further use cases or experiment with different parameters to fully leverage the potential of this API!