Generate Stunning Images with AI-Linear2 Cognitive Actions

In the world of image generation, the AI-Linear2 API by Marios Romano offers powerful tools that allow developers to create stunning visuals with ease. The Generate Image with AI-Linear action leverages advanced AI models to produce high-quality images tailored to your specifications. Whether you need speed or intricate details, this action provides customizable parameters to meet your needs, including aspect ratios, image quality, and output formats.
Prerequisites
Before diving into the Cognitive Actions, ensure you have the following prerequisites:
- An API key for accessing the Cognitive Actions platform.
- Familiarity with sending HTTP requests and handling JSON data.
- A Python environment set up with the
requestslibrary for making API calls.
To authenticate with the API, you will need to pass your API key in the request headers.
Cognitive Actions Overview
Generate Image with AI-Linear
The Generate Image with AI-Linear action is designed to create high-quality or fast-mode images using AI-Linear models. This action supports inpainting and image-to-image transformations, allowing for advanced customization of generated images.
Input
The input for this action is structured as follows:
{
"prompt": "point of view going up an escalator, a yellow AI-linear walls on each side, ",
"loraScale": 1,
"modelType": "dev",
"numOutputs": 4,
"aspectRatio": "1:1",
"outputFormat": "png",
"guidanceScale": 2,
"outputQuality": 90,
"enableFastMode": false,
"extraLoraScale": 1,
"promptStrength": 0.8,
"imageMegapixels": "1",
"numInferenceSteps": 28
}
Required Fields:
prompt: A textual description guiding the image generation.
Optional Fields:
mask: Image mask for inpainting mode.seed: Random seed for reproducibility.image: Input image for image-to-image transformation.widthandheight: Define custom dimensions (if applicable).loraScale,modelType,numOutputs,aspectRatio,outputFormat,guidanceScale,outputQuality,enableFastMode,extraLoraScale,promptStrength,imageMegapixels,numInferenceSteps: Parameters to control the image generation process.
Output
Upon successful execution, the action returns an array of image URLs. For example:
[
"https://assets.cognitiveactions.com/invocations/245c9c4b-f64e-47ce-957e-9488387c2389/8dbacae4-af47-47be-b52d-b788b67c4bcd.png",
"https://assets.cognitiveactions.com/invocations/245c9c4b-f64e-47ce-957e-9488387c2389/4f046d91-209a-4b61-8d30-9e15f7f55792.png",
"https://assets.cognitiveactions.com/invocations/245c9c4b-f64e-47ce-957e-9488387c2389/2d6e6c04-d587-4a74-9454-a58ca3bbe456.png",
"https://assets.cognitiveactions.com/invocations/245c9c4b-f64e-47ce-957e-9488387c2389/957d3ef1-cd3e-47bd-9186-939fd011ce41.png"
]
This output contains the URLs of the generated images, which can be displayed or downloaded as needed.
Conceptual Usage Example (Python)
Here’s a conceptual example of how you might call the Generate Image with AI-Linear 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 = "63ea8acf-6d5a-4a04-a4e4-80a2741d4aae" # Action ID for Generate Image with AI-Linear
# Construct the input payload based on the action's requirements
payload = {
"prompt": "point of view going up an escalator, a yellow AI-linear walls on each side, ",
"loraScale": 1,
"modelType": "dev",
"numOutputs": 4,
"aspectRatio": "1:1",
"outputFormat": "png",
"guidanceScale": 2,
"outputQuality": 90,
"enableFastMode": False,
"extraLoraScale": 1,
"promptStrength": 0.8,
"imageMegapixels": "1",
"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 example, replace YOUR_COGNITIVE_ACTIONS_API_KEY with your actual API key. The payload variable is structured according to the input schema for the action. The response will contain the generated image URLs, which you can use in your application.
Conclusion
The AI-Linear2 Cognitive Actions offer a powerful way to generate images with customizable parameters that fit your specific needs. By leveraging actions like Generate Image with AI-Linear, developers can create visually appealing content efficiently. As you explore these capabilities, consider experimenting with different parameters to optimize your image generation process. Happy coding!