Create Stunning Images Effortlessly with Coach P Cognitive Actions

In the realm of AI-driven creativity, the bsandmg/coachp API offers developers a powerful tool through its Cognitive Actions. These actions are designed to simplify the process of generating customized images using advanced features like LoRA intensity and prompt strength. By utilizing these pre-built actions, developers can achieve high-quality image outputs with minimal effort, enhancing their applications with unique visual content.
Prerequisites
To get started with the Coach P Cognitive Actions, you'll need to have an API key for the Cognitive Actions platform. This key will be used for authentication when making requests. Conceptually, you would pass this API key in the headers of your HTTP requests to ensure secure access to the image generation functionalities.
Cognitive Actions Overview
Generate Coach P Image
The Generate Coach P Image action allows you to create customized images using the Coach P model. It features various options for image generation, including the ability to specify the model, dimensions, and quality of the output.
Input
The input for this action is structured as a JSON object, which requires the following fields:
- prompt (required): A descriptive string that guides the generation of the image.
- model (optional): Specifies the model for inference, either "dev" or "schnell".
- width and height (optional): Define the dimensions of the image when aspect ratio is set to custom.
- aspectRatio (optional): Specifies the desired aspect ratio of the generated image.
- guidanceScale, loraIntensity, promptStrength, and other optional parameters control various aspects of image generation.
Example Input:
{
"model": "dev",
"width": 775,
"height": 783,
"prompt": "\"Create an anime-style portrait of a black male character, MPNOLA with the following characteristics:\nClean, smooth lines\nVibrant, soft colors (like pastels)\nSlightly smiling facial features\nexpressive eyes with highlights\nSoft shading for depth\nShort hair, fade, mustache \nA warm, friendly smile\nWearing glasses\nDressed in a dark grey suit with a blue tie\nBlack shoes visible\nStanding in front of a school building wide view",
"aspectRatio": "1:1",
"guidanceScale": 3.5,
"loraIntensity": 1,
"promptStrength": 0.8,
"numberOfOutputs": 2,
"imageOutputFormat": "webp",
"imageOutputQuality": 90,
"numberOfInferenceSteps": 28,
"additionalLoraIntensity": 1
}
Output
The action typically returns an array of URLs pointing to the generated images. Each URL corresponds to an output image created based on the provided prompt and configurations.
Example Output:
[
"https://assets.cognitiveactions.com/invocations/dd0b0404-0ede-49aa-8c06-ab809a2f971e/0bc6c662-7e54-4cf7-b3ab-8a37c910e92e.webp",
"https://assets.cognitiveactions.com/invocations/dd0b0404-0ede-49aa-8c06-ab809a2f971e/9d5ae28d-1fef-4b4a-abe5-7b4c73bbf694.webp"
]
Conceptual Usage Example (Python)
Here’s a conceptual Python code snippet demonstrating how to call the Generate Coach P Image action using a hypothetical Cognitive Actions execution endpoint:
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 = "5de21d2d-6243-40ba-bf28-f0597835b8ed" # Action ID for Generate Coach P Image
# Construct the input payload based on the action's requirements
payload = {
"model": "dev",
"width": 775,
"height": 783,
"prompt": "\"Create an anime-style portrait of a black male character, MPNOLA with the following characteristics:\nClean, smooth lines\nVibrant, soft colors (like pastels)\nSlightly smiling facial features\nexpressive eyes with highlights\nSoft shading for depth\nShort hair, fade, mustache \nA warm, friendly smile\nWearing glasses\nDressed in a dark grey suit with a blue tie\nBlack shoes visible\nStanding in front of a school building wide view",
"aspectRatio": "1:1",
"guidanceScale": 3.5,
"loraIntensity": 1,
"promptStrength": 0.8,
"numberOfOutputs": 2,
"imageOutputFormat": "webp",
"imageOutputQuality": 90,
"numberOfInferenceSteps": 28,
"additionalLoraIntensity": 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 snippet, remember to replace the COGNITIVE_ACTIONS_API_KEY with your actual API key and adjust the endpoint URL as necessary. The input JSON payload is structured to match the requirements of the Generate Coach P Image action, ensuring a smooth execution.
Conclusion
The Coach P Cognitive Actions provide developers with an innovative solution for generating customized images effortlessly. By leveraging these actions, you can enhance your applications with high-quality visuals tailored to specific needs. Consider experimenting with different prompts and configurations to explore the full potential of the image generation capabilities offered by this powerful API. Start integrating and unleash your creativity today!