Create Stunning CGA Style Images with the Cybermerlo Cognitive Actions

Integrating Cognitive Actions into your applications can unlock powerful capabilities, particularly in areas like image generation. The Cybermerlo Cognitive Actions provide a unique opportunity for developers to create images in the classic CGA PC game style, offering customizable parameters for varied outputs. This blog post will guide you through the Generate CGA Style Images action, detailing how to utilize its features effectively.
Prerequisites
Before diving into the integration, ensure you have the following:
- API Key: You will need an API key to authenticate your requests to the Cognitive Actions platform.
- Endpoint Setup: Familiarize yourself with the endpoint structure for executing actions. Conceptually, you will be passing your API key in the request headers.
Cognitive Actions Overview
Generate CGA Style Images
The Generate CGA Style Images action allows you to create images reminiscent of classic CGA PC games. You can customize various settings such as image inpainting, resolution, and aspect ratios, while the action supports different models for varying speeds and quality of inference.
Input
The input for this action requires a structured JSON payload. Below is the schema for the input, along with an example:
Input Schema:
- prompt (required): Text prompt used to generate the image.
- mask (optional): Image mask for inpainting mode.
- seed (optional): Random seed for deterministic outputs.
- image (optional): Input image for inpainting mode.
- width (optional): Width of the generated image.
- height (optional): Height of the generated image.
- goFast (optional): Enable model optimized for speed.
- aspectRatio (optional): Defines the aspect ratio of the output image.
- numOutputs (optional): Specifies the number of images to generate (1 to 4).
- imageFormat (optional): Determines the file format of the generated images.
- guidanceScale (optional): Sets the guidance scale for the diffusion process.
- outputQuality (optional): Controls the quality of output images (0-100).
- numInferenceSteps (optional): Sets the number of denoising steps.
Example Input:
{
"prompt": "Surreal collage: person split into multiple versions, each doing different activities. Central 28-hour clock. Scenes show sleeping, reading, exercising, painting, and socializing. Background sky split between day and night, with visible stars and sun. Vivid colors, dreamlike transitions between scenes. CGA",
"loraScale": 1,
"modelType": "dev",
"numOutputs": 1,
"aspectRatio": "1:1",
"imageFormat": "webp",
"guidanceScale": 3.5,
"outputQuality": 90,
"extraLoraScale": 1,
"promptStrength": 0.8,
"numInferenceSteps": 28
}
Output
Upon successful execution, the action typically returns an array of URLs pointing to the generated images. Here's an example of what the output might look like:
Example Output:
[
"https://assets.cognitiveactions.com/invocations/48a987aa-b2cc-4a24-93c6-81758318cef9/2d7468db-9f70-4b2f-b71d-8095ab322dca.webp"
]
Conceptual Usage Example (Python)
Below is a Python code snippet that demonstrates how to call the Generate CGA Style Images action using a hypothetical Cognitive Actions endpoint. This example focuses on structuring the input JSON payload correctly.
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 = "5ea9e179-1968-46b6-acfd-906809b35518" # Action ID for Generate CGA Style Images
# Construct the input payload based on the action's requirements
payload = {
"prompt": "Surreal collage: person split into multiple versions, each doing different activities. Central 28-hour clock. Scenes show sleeping, reading, exercising, painting, and socializing. Background sky split between day and night, with visible stars and sun. Vivid colors, dreamlike transitions between scenes. CGA",
"loraScale": 1,
"modelType": "dev",
"numOutputs": 1,
"aspectRatio": "1:1",
"imageFormat": "webp",
"guidanceScale": 3.5,
"outputQuality": 90,
"extraLoraScale": 1,
"promptStrength": 0.8,
"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 is structured based on the required input fields, making it easy to generate images in the desired style.
Conclusion
The Generate CGA Style Images Cognitive Action is a powerful tool for developers looking to create unique and visually engaging images. By leveraging the customizable parameters, you can fine-tune the outputs to meet your needs. Whether for a game, art project, or personal use, the possibilities are endless. Start experimenting with this action today and elevate your applications with stunning visuals!