Enhance Your Applications with Image Generation Using dunaevai135/tst_agt_4 Cognitive Actions

In today’s digital landscape, generating high-quality images programmatically can enhance user engagement and streamline creative processes. The Cognitive Actions provided by the dunaevai135/tst_agt_4 specification empower developers to leverage advanced image generation models. These actions support various features such as image inpainting, multiple output formats, and customizable parameters, allowing for flexibility and precision in generating visuals.
Prerequisites
Before diving into the Cognitive Actions, ensure you have the following:
- An API key for the Cognitive Actions platform. This key is essential for authenticating your requests.
- Basic understanding of making API calls, particularly using JSON as the request payload.
To authenticate your requests, you will typically pass the API key in the headers of your HTTP requests.
Cognitive Actions Overview
Generate Enhanced Images
Purpose
The Generate Enhanced Images action allows you to create images using advanced models optimized for both speed and detail. This action supports features such as image inpainting, multiple output formats, and customizable settings, making it ideal for various use cases in image generation.
Input
The input schema for this action is defined as follows:
{
"prompt": "string", // A required field that describes the image to generate.
"seed": "integer", // Optional random seed for reproducible results.
"model": "string", // Optional model choice; 'dev' for quality or 'schnell' for speed.
"width": "integer", // Optional width in pixels (when aspectRatio is 'custom').
"goFast": "boolean", // Optional toggle for faster predictions.
"height": "integer", // Optional height in pixels (when aspectRatio is 'custom').
"extraLora": "string", // Optional additional LoRA weights.
"imageMask": "string", // Optional URI for inpainting mode.
"loraScale": "number", // Optional intensity of the main LoRA application.
"inputImage": "string", // Optional URI for input image in image-to-image mode.
"megapixels": "string", // Optional targeted resolution in megapixels.
"aspectRatio": "string", // Optional aspect ratio of the image.
"loraWeights": "string", // Optional LoRA weights.
"outputFormat": "string", // Optional output format (webp, jpg, png).
"guidanceScale": "number", // Optional guidance scale for image generation.
"outputQuality": "integer", // Optional quality of the output image.
"extraLoraScale": "number", // Optional strength of the extra LoRA application.
"promptStrength": "number", // Optional strength of the prompt in image-to-image tasks.
"numberOfOutputs": "integer", // Optional number of outputs to generate.
"numInferenceSteps": "integer", // Optional number of inference steps.
"isSafetyCheckerDisabled": "boolean" // Optional toggle to disable safety checks.
}
Example Input:
{
"model": "dev",
"prompt": "professional photo of AGT, beautiful woman, punk stile",
"loraScale": 1,
"aspectRatio": "1:1",
"outputFormat": "webp",
"guidanceScale": 3.5,
"outputQuality": 90,
"extraLoraScale": 1,
"promptStrength": 0.65,
"numberOfOutputs": 2,
"numInferenceSteps": 28
}
Output
Upon executing the action, you can expect a response containing the generated image URLs. Here’s an example of what the output might look like:
[
"https://assets.cognitiveactions.com/invocations/c9cfb6f8-448c-449d-9a00-d5fe16dac4c7/b0cabe80-45a0-4b49-a7d9-dd95de20383c.webp",
"https://assets.cognitiveactions.com/invocations/c9cfb6f8-448c-449d-9a00-d5fe16dac4c7/d263629f-63b8-42f2-8422-bdd9e489da91.webp"
]
Conceptual Usage Example (Python)
Here’s how you could structure a call to 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 = "9c2309d6-e9f2-434d-908e-21a62c44ebb2" # Action ID for Generate Enhanced Images
# Construct the input payload based on the action's requirements
payload = {
"model": "dev",
"prompt": "professional photo of AGT, beautiful woman, punk stile",
"loraScale": 1,
"aspectRatio": "1:1",
"outputFormat": "webp",
"guidanceScale": 3.5,
"outputQuality": 90,
"extraLoraScale": 1,
"promptStrength": 0.65,
"numberOfOutputs": 2,
"numInferenceSteps": 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 Python snippet, replace the placeholder API key and endpoint with your actual values. The action_id corresponds to the action you wish to execute. The payload is structured based on the required input fields.
Conclusion
Integrating the Generate Enhanced Images action from the dunaevai135/tst_agt_4 specification into your applications can significantly enhance your image generation capabilities. With customizable parameters and support for various output formats, developers can create stunning visuals tailored to specific needs. Consider exploring additional features and use cases to fully leverage the power of Cognitive Actions in your projects.