Generate Stunning Images with the natta613/nat-1-kai Cognitive Actions

In the world of digital content creation, having the ability to generate unique, high-quality images on demand can significantly enhance your applications. The natta613/nat-1-kai Cognitive Actions provide powerful tools for image generation, allowing developers to create customized images using text prompts, image masks, and a variety of parameters. By leveraging these pre-built actions, you can streamline your image generation process while maintaining control over speed and quality.
Prerequisites
To get started with the Cognitive Actions, you'll need to acquire an API key for the Cognitive Actions platform. This key will be used to authenticate your requests. Typically, you will include the API key in the headers of your API calls. Make sure to check the documentation for any specific setup required to access the API.
Cognitive Actions Overview
Generate Image With Custom Parameters
The Generate Image With Custom Parameters action allows you to create customized images based on your specifications. You can specify various parameters, including text prompts and image masks, to achieve the desired results.
Input
The input for this action is structured as follows:
- imagePrompt (required): The text prompt that describes the image you want to generate.
- image (optional): An input image for inpainting or image-to-image generation.
- imageMask (optional): An image mask for inpainting.
- aspectRatio (optional): Determines the aspect ratio of the generated image. Default is
1:1. - imageWidth (optional): Specifies the width of the generated image (only for custom aspect ratios).
- imageHeight (optional): Specifies the height of the generated image (only for custom aspect ratios).
- outputCount (optional): The number of images to generate (default is 1).
- imageFormat (optional): The output image format (default is
webp). - imageQuality (optional): The quality of the output image, from 0 to 100 (default is 80).
- Additional parameters for control over the generation process, such as
randomSeed,denoisingSteps, andinferenceModel.
Here’s an example of a JSON payload that can be used to invoke this action:
{
"imagePrompt": "Full-length wide-angle shot of Asian man my kai, mohawk, purple hair, handsome face, looking at the camera, black leather jacket, working, walking in the city at night, buildings and condos, many people, bright image, focus on the lights, in Thailand.",
"aspectRatio": "9:16",
"imageFormat": "png",
"outputCount": 1,
"imageQuality": 90,
"promptImpact": 0.8,
"mainLoraScale": 1,
"denoisingSteps": 39,
"inferenceModel": "dev",
"influenceScale": 3.5,
"additionalLoraScale": 1
}
Output
The output of this action is typically a URL linking to the generated image. Here’s an example of what you might receive:
[
"https://assets.cognitiveactions.com/invocations/ebe9cd7e-38e3-4dc2-88c0-db96e11a445e/7e0374ed-44f8-48f0-80a3-3b17caeed9e3.png"
]
Conceptual Usage Example (Python)
Below is a conceptual Python code snippet demonstrating how to call the Generate Image With Custom Parameters action:
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 = "311825d4-82b9-4e19-ad76-c48aeded04e4" # Action ID for Generate Image With Custom Parameters
# Construct the input payload based on the action's requirements
payload = {
"imagePrompt": "Full-length wide-angle shot of Asian man my kai, mohawk, purple hair, handsome face, looking at the camera, black leather jacket, working, walking in the city at night, buildings and condos, many people, bright image, focus on the lights, in Thailand.",
"aspectRatio": "9:16",
"imageFormat": "png",
"outputCount": 1,
"imageQuality": 90,
"promptImpact": 0.8,
"mainLoraScale": 1,
"denoisingSteps": 39,
"inferenceModel": "dev",
"influenceScale": 3.5,
"additionalLoraScale": 1
}
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 replace the API key and endpoint with your actual credentials. The payload is structured according to the action's input schema, and the response is handled to provide you with the generated image URL.
Conclusion
The natta613/nat-1-kai Cognitive Actions offer a robust solution for developers looking to integrate custom image generation into their applications. By using the Generate Image With Custom Parameters action, you can create stunning visuals tailored to your specific needs. Experiment with various parameters to see how they affect the generated images, and unlock new possibilities for your projects!