Generate Stunning Images with the Jenny Cognitive Actions

In the rapidly evolving landscape of artificial intelligence, the ability to generate images programmatically is a game-changer for developers. The Jenny Cognitive Actions provide a powerful API that enables developers to create images using customized parameters, such as aspect ratio, resolution, and model type. These pre-built actions simplify the image generation process, allowing you to focus on your application while leveraging advanced capabilities like image inpainting and customizable settings.
Prerequisites
Before you dive into using the Jenny Cognitive Actions, ensure you have the following:
- An API key for accessing the Cognitive Actions platform.
- Basic knowledge of JSON and RESTful API concepts.
- Familiarity with Python for making API calls and handling responses.
Authentication is typically handled by passing your API key in the request headers. This allows you to securely access the services provided by the Jenny API.
Cognitive Actions Overview
Generate Image with Custom Settings
The Generate Image with Custom Settings action allows you to create images based on a detailed text prompt while providing options for customization. This includes settings for aspect ratio, resolution, model type, and more. It supports different modes like image-to-image and inpainting, ensuring your creative vision can be realized with precision.
Input
The input schema for this action requires a JSON object with the following fields:
- prompt (required): A text prompt to guide the image generation.
- model: The inference model to use, either "dev" for detailed rendering or "schnell" for faster execution.
- aspectRatio: The desired aspect ratio of the output image.
- width and height: Custom dimensions, applicable when aspect ratio is set to custom.
- seed: A random seed for reproducibility.
- image: An input image for image-to-image mode.
- mask: An image mask for specifying areas in inpainting mode.
- Various other parameters to fine-tune the generation process.
Here’s an example input JSON payload:
{
"mask": "https://replicate.delivery/pbxt/MUSRaVZ1zIUVCX6FBTi07AA9KdYda1UTQKZvSXcsc0VRaFqj/2012-03-2913.59.0450344.6955.jpg",
"model": "dev",
"goFast": false,
"prompt": "jenny, A cozy café scene, sitting by a wooden table, deeply immersed in reading a book. Warm golden sunlight streaming through the window, softly illuminating her face. A cup of steaming coffee beside her, slight steam rising. The background is slightly blurred, with bookshelves and a rustic interior filled with warm tones. Captured in a cinematic, high-resolution shot, gentle depth of field, realistic skin texture, natural lighting, cozy and atmospheric mood\n",
"loraScale": 1,
"megapixels": "1",
"aspectRatio": "1:1",
"guidanceLevel": 3,
"outputQuality": 80,
"extraLoraScale": 1,
"inferenceSteps": 28,
"promptStrength": 0.8,
"numberOfOutputs": 1,
"imageOutputFormat": "webp"
}
Output
The output of this action is typically a URL pointing to the generated image. For example:
[
"https://assets.cognitiveactions.com/invocations/12eb6e62-e887-464a-950b-45b9fff6bf1c/54689fcc-137b-44da-9c84-13cc425c3033.webp"
]
This URL will direct you to the generated image, allowing you to view or download it.
Conceptual Usage Example (Python)
Here’s how you might call the Generate Image with Custom Settings 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 = "2d1ea2ee-b0be-487a-b836-cd9970cb39d5" # Action ID for Generate Image with Custom Settings
# Construct the input payload based on the action's requirements
payload = {
"mask": "https://replicate.delivery/pbxt/MUSRaVZ1zIUVCX6FBTi07AA9KdYda1UTQKZvSXcsc0VRaFqj/2012-03-2913.59.0450344.6955.jpg",
"model": "dev",
"goFast": False,
"prompt": "jenny, A cozy café scene, sitting by a wooden table, deeply immersed in reading a book. Warm golden sunlight streaming through the window, softly illuminating her face. A cup of steaming coffee beside her, slight steam rising. The background is slightly blurred, with bookshelves and a rustic interior filled with warm tones. Captured in a cinematic, high-resolution shot, gentle depth of field, realistic skin texture, natural lighting, cozy and atmospheric mood\n",
"loraScale": 1,
"megapixels": "1",
"aspectRatio": "1:1",
"guidanceLevel": 3,
"outputQuality": 80,
"extraLoraScale": 1,
"inferenceSteps": 28,
"promptStrength": 0.8,
"numberOfOutputs": 1,
"imageOutputFormat": "webp"
}
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 constructed according to the input schema, and a POST request is made to the hypothetical execution endpoint.
Conclusion
The Jenny Cognitive Actions provide a versatile and powerful way to generate images tailored to your specifications. With the ability to customize various parameters, developers can create stunning visuals that enhance their applications. Start integrating these actions today and unlock new possibilities in your projects!