Create Stunning Images with MiniMax Cognitive Actions

The MiniMax Image-01 Cognitive Actions provide developers with powerful tools to generate high-quality images from textual prompts. This text-to-image model excels in producing intricate details, realistic human renderings, and complex scene compositions, making it a fantastic addition to any application that requires image creation based on user input. By leveraging these pre-built actions, developers can save time and effort while enhancing their applications with visually appealing content.
Prerequisites
To get started with the MiniMax Cognitive Actions, you will need:
- An API key for accessing the Cognitive Actions platform.
- Basic knowledge of making HTTP requests and handling JSON data.
Authentication typically involves passing your API key in the request headers to ensure secure access to the Cognitive Actions.
Cognitive Actions Overview
Generate Image with MiniMax
Description: This action creates high-quality images using the MiniMax Image-01 model based on a given text prompt. It's particularly known for its detailed lighting and realistic human rendering capabilities.
- Category: Image Generation
Input
The input for the Generate Image with MiniMax action requires the following fields:
- prompt (required): A string that describes the features and characteristics of the desired output.
Example:"A close-up portrait of a leopard with distinctive spotted pattern and intense eyes" - aspectRatio (optional): Specifies the width to height dimensions of the image. Default is
1:1.
Example:"3:4" - numberOfImages (optional): Specifies how many images to generate in a single request. Default is
1, and it must be between1and9.
Example:1 - usePromptOptimizer (optional): A boolean that determines whether to optimize the prompt for better generation results. Default is
true.
Example:true
Example Input:
{
"prompt": "A close-up portrait of a leopard with distinctive spotted pattern and intense eyes",
"aspectRatio": "3:4",
"numberOfImages": 1,
"usePromptOptimizer": true
}
Output
The output of the action is a list of URLs pointing to the generated images. Each URL corresponds to an image that was created based on the input prompt.
Example Output:
[
"https://assets.cognitiveactions.com/invocations/c3f88051-dccd-4d5e-b4b8-ce830d0efd62/e5d8bde8-751b-41b7-8032-4cc083b4af89.jpg"
]
Conceptual Usage Example (Python)
Here is a conceptual Python code snippet showing how a developer might call the MiniMax 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 = "c2bb88ab-d447-4eec-b975-c8e774ac4f00" # Action ID for Generate Image with MiniMax
# Construct the input payload based on the action's requirements
payload = {
"prompt": "A close-up portrait of a leopard with distinctive spotted pattern and intense eyes",
"aspectRatio": "3:4",
"numberOfImages": 1,
"usePromptOptimizer": True
}
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, the developer defines the action ID and constructs the input payload according to the action's requirements. The HTTP request is sent to the hypothetical Cognitive Actions endpoint, and the results are printed once the action is executed successfully.
Conclusion
The MiniMax Cognitive Actions offer developers a powerful way to generate stunning images based on textual descriptions easily. By integrating these actions into applications, developers can enhance user experiences through rich visual content. Consider exploring various prompts and configurations to fully utilize the capabilities of the MiniMax Image-01 model in your projects!