Generate Stunning Custom Images with Aisha AI's Anillustrious-v4 Cognitive Actions

In the realm of artificial intelligence, the ability to create custom images from textual prompts is becoming increasingly accessible and powerful. The Anillustrious-v4 Cognitive Actions provide developers with the tools to generate high-quality images tailored to specific requirements. Whether you're building an app that requires unique illustrations or want to create visual content from descriptive text, these pre-built actions streamline the process, allowing you to focus on your application rather than the underlying complexities of image generation.
Prerequisites
Before diving into the integration of Cognitve Actions, ensure you have the following:
- An API key for the Cognitive Actions platform.
- Familiarity with sending HTTP requests and handling JSON data.
- A development environment set up to run Python code (or other language of your choice).
Conceptually, authentication typically involves including your API key in the request headers. This ensures that only authorized users can access the Cognitive Actions.
Cognitive Actions Overview
Generate Custom Images
The Generate Custom Images action utilizes the Anillustrious-v4 model to create images based on your textual prompts. You can finely tune the generation process by configuring various parameters, including dimensions, steps, and enhancement options.
Category: Image Generation
Input: The input payload for this action requires several fields. Here's a breakdown of the expected schema along with an example input:
{
"seed": -1,
"steps": 30,
"width": 1080,
"height": 1080,
"prompt": "street, 1girl, dark-purple short hair, purple eyes, medium breasts, cleavage, casual clothes, smile, V",
"refiner": false,
"vaeType": "NeptuniaXL-VAE-ContrastSaturation",
"cfgScale": 7,
"clipSkip": 2,
"pagScale": 0,
"modelType": "Anillustrious-v4",
"refinerPrompt": "",
"schedulerType": "Euler a",
"upscaleFactor": "Original",
"negativePrompt": "nsfw, naked",
"guidanceRescale": 1,
"refinerStrength": 0.4,
"prependPreprompt": true,
"detailerFacePrompt": "",
"detailerHandPrompt": "",
"detailerFaceEnabled": false,
"detailerHandEnabled": false,
"detailerPersonPrompt": "",
"detailerPersonEnabled": false,
"detailerFaceNegativePrompt": "",
"detailerHandNegativePrompt": "",
"detailerPersonNegativePrompt": ""
}
Output: Upon successful execution, this action returns a URL pointing to the generated image. For example:
[
"https://assets.cognitiveactions.com/invocations/f470c2e3-8552-442d-a2e7-63cc112bce48/b4d345f7-a1dd-47b3-97fc-7e6eb8e75933.png"
]
Conceptual Usage Example (Python)
Here’s how you might call the Generate Custom Images action using Python. This example illustrates the structure of the input JSON payload and how to make the request:
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 = "ccb7594b-b194-4789-b8c7-4ee1cd3507c5" # Action ID for Generate Custom Images
# Construct the input payload based on the action's requirements
payload = {
"seed": -1,
"steps": 30,
"width": 1080,
"height": 1080,
"prompt": "street, 1girl, dark-purple short hair, purple eyes, medium breasts, cleavage, casual clothes, smile, V",
"refiner": False,
"vaeType": "NeptuniaXL-VAE-ContrastSaturation",
"cfgScale": 7,
"clipSkip": 2,
"pagScale": 0,
"modelType": "Anillustrious-v4",
"refinerPrompt": "",
"schedulerType": "Euler a",
"upscaleFactor": "Original",
"negativePrompt": "nsfw, naked",
"guidanceRescale": 1,
"refinerStrength": 0.4,
"prependPreprompt": True,
"detailerFacePrompt": "",
"detailerHandPrompt": "",
"detailerFaceEnabled": False,
"detailerHandEnabled": False,
"detailerPersonPrompt": "",
"detailerPersonEnabled": False,
"detailerFaceNegativePrompt": "",
"detailerHandNegativePrompt": "",
"detailerPersonNegativePrompt": ""
}
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_KEY" with your actual API key. The action_id is set to target the Generate Custom Images action. The payload includes all necessary parameters to generate the image. The response will contain the URL of the generated image, which you can utilize in your application.
Conclusion
The Anillustrious-v4 Cognitive Actions open up a world of possibilities for developers looking to integrate custom image generation into their applications. With the ability to control various parameters—such as dimensions, seeding, and refinement—you can tailor the output to meet your specific needs. Start exploring the capabilities of these actions today and enhance your applications with stunning visual content!