Create Stunning Images with the asiryan/blue-pencil-xl-v2 Cognitive Actions

In the realm of digital creativity, the asiryan/blue-pencil-xl-v2 API offers developers an exciting opportunity to leverage advanced image generation techniques. With its powerful Cognitive Actions, you can create high-quality images through various methods such as Text2Img, Img2Img, and Inpainting. These pre-built actions simplify the integration of sophisticated image creation capabilities into your applications, enhancing both speed and accuracy.
Prerequisites
Before diving into the image generation capabilities, ensure you have the following:
- An API key for accessing the Cognitive Actions platform.
- Basic knowledge of JSON and RESTful API concepts.
- Familiarity with making API requests using your preferred programming language.
Authentication typically involves passing the API key in the headers of your requests, ensuring secure access to the Cognitive Actions.
Cognitive Actions Overview
Generate Image Using Blue Pencil XL v2
Description:
This action utilizes the Blue Pencil XL v2 Model to create images based on user-defined prompts, images, or masks. With options for adjustment and fine-tuning, you can produce images that meet specific creative needs.
Category: Image Generation
Input: The input for this action is structured as a JSON object with the following fields:
- prompt (string): Describes the desired output image.
- image (string, optional): URI of an image for Img2Img or inpainting.
- mask (string, optional): URI for an input mask used in inpainting.
- width (integer, default: 1024): Width of the output image.
- height (integer, default: 1024): Height of the output image.
- seed (integer, optional): Random seed for generation.
- strength (number, default: 0.8): Strength for img2img/inpaint mode.
- guidanceScale (number, default: 7): Scale for classifier-free guidance.
- negativePrompt (string, optional): Traits to avoid in the output image.
- numberOfOutputs (integer, default: 1): Number of images to generate (1 to 4).
- numberOfInferenceSteps (integer, default: 40): Number of denoising steps (1 to 500).
- scheduler (string, default: "K_EULER_ANCESTRAL"): Scheduler algorithm.
- loraScale (number, default: 0.6): Scale factor for LoRA model's influence.
- loraWeights (string, optional): URI for LoRA weights.
Example Input:
{
"seed": 2089584936,
"width": 1024,
"height": 1024,
"prompt": "anime, illustration, sketch, girl, little smile, scenery, seaside, wind",
"strength": 0.75,
"guidanceScale": 7.5,
"numberOfInferenceSteps": 50
}
Output: The action returns a list of URIs for the generated images. An example output is shown below:
[
"https://assets.cognitiveactions.com/invocations/bd705c57-c944-4eaa-8a7b-1d9eef6b468d/9f8cb4b3-044a-4439-8189-0f34e97cdb34.png"
]
Conceptual Usage Example (Python): Here's how you might structure a request to execute this 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 = "10185293-63f2-48e2-8d4d-8d103e6ea961" # Action ID for Generate Image Using Blue Pencil XL v2
# Construct the input payload based on the action's requirements
payload = {
"seed": 2089584936,
"width": 1024,
"height": 1024,
"prompt": "anime, illustration, sketch, girl, little smile, scenery, seaside, wind",
"strength": 0.75,
"guidanceScale": 7.5,
"numberOfInferenceSteps": 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 snippet, replace the placeholder with your actual API key and adjust the input payload as needed. This provides a clear structure for developers looking to integrate the action into their applications.
Conclusion
The asiryan/blue-pencil-xl-v2 Cognitive Actions enable developers to harness the power of advanced image generation, making it easier than ever to create stunning visuals. By understanding the input requirements and leveraging the provided examples, you can seamlessly integrate these capabilities into your projects. Explore different prompts, strengths, and settings to discover the full potential of this innovative API!