Create Stunning Custom Images with Gioa's Image Generation Action

Gioa offers a powerful image generation service that allows developers to create custom images based on user-defined prompts and masks. With the ability to perform image-to-image transformations and inpainting, Gioa simplifies the process of generating high-quality visuals tailored to specific needs. Whether you’re looking to create artwork, design assets, or unique graphics for your projects, Gioa enhances your workflow by providing flexibility in image generation through adjustable parameters like resolution, aspect ratio, and output quality.
Common use cases for Gioa’s image generation capabilities include creating marketing materials, producing illustrations for blogs or websites, generating concept art for games, and even crafting personalized images for social media campaigns. By leveraging Gioa, developers can save time and resources while achieving stunning visual results that meet their creative visions.
Prerequisites
To get started with Gioa's Cognitive Actions, you will need an API key for authentication and a basic understanding of how to make API calls.
Generate Image with Custom Mask
The "Generate Image with Custom Mask" action allows you to create images using a specified mask along with a descriptive prompt. This action supports various modes for transforming existing images or filling in details with inpainting. It also offers adjustable settings like resolution and aspect ratio, ensuring that the output meets your specific requirements. The flexibility of using either the 'dev' model for detailed generation or the 'schnell' model for faster results provides developers with the ability to choose according to their project needs.
Input Requirements
To utilize this action, you need to provide a JSON object containing the following parameters:
- prompt (string): A descriptive text that guides the image generation.
- mask (string, optional): A URI pointing to an image mask for inpainting.
- image (string, optional): A URI for an input image if performing transformations.
- width (integer, optional): Desired width of the output image (if using custom aspect ratio).
- height (integer, optional): Desired height of the output image (if using custom aspect ratio).
- Additional parameters include seed, output format, quality, and model selection.
Expected Output
The output will be a URI pointing to the generated image based on the provided prompt and parameters. For example:
[
"https://assets.cognitiveactions.com/invocations/e076901d-ffd5-480e-99bc-d39efa0a1308/3b3c169f-68a8-4355-b1a8-79de6d41d903.webp"
]
Use Cases for this Specific Action
- Marketing and Advertising: Create eye-catching visuals for campaigns that stand out and attract attention.
- Concept Art Generation: Quickly produce sketches or concept designs for games or animation projects.
- Personalized Gifts: Generate unique images that can be used in custom merchandise or gifts.
- Social Media Content: Design tailored graphics that resonate with target audiences and enhance engagement.
import requests
import json
# Replace with your actual Cognitive Actions API key and endpoint
# Ensure your environment securely handles the API key
COGNITIVE_ACTIONS_API_KEY = "YOUR_COGNITIVE_ACTIONS_API_KEY"
# This endpoint URL is hypothetical and should be documented for users
COGNITIVE_ACTIONS_EXECUTE_URL = "https://api.cognitiveactions.com/actions/execute"
action_id = "621e73c3-d91c-4a04-8ea3-a58aad270c46" # Action ID for: Generate Image with Custom Mask
# Construct the exact input payload based on the action's requirements
# This example uses the predefined example_input for this action:
payload = {
"prompt": "gioa like a professional male cyclist, wearing a tight, sleek white and black cycling suit that hugs his form, resembling the outfit of a nocturnal superhero. His attire features subtle armor-like details and dark textures, emphasizing strength and agility. The cyclist has a slim but well-defined muscular build, with his toned arms and legs clearly visible. He also has a piercing on his right eyebrow and another on his left ear, adding a rebellious edge to his look. He is riding a modern road bike in a dynamic forward-leaning pose, against a black background, creating a sense of speed and focus. His face is clearly visible, without any sunglasses, and his expression conveys determination. The scene is illuminated with two neon lights, one blue and one pink, casting a vibrant, futuristic glow over the cyclist and his bike, highlighting the contours of his muscles and the aerodynamic design. The overall mood evokes power, stealth, and intensity, blending the world of sports, rebellion, and heroism.",
"mainLoraScale": 1,
"inferenceModel": "dev",
"numberOfOutputs": 1,
"imageAspectRatio": "1:1",
"imageOutputFormat": "webp",
"imageOutputQuality": 90,
"inferenceStepCount": 28,
"additionalLoraScale": 1,
"imagePromptStrength": 0.8,
"diffusionGuidanceScale": 3.5
}
headers = {
"Authorization": f"Bearer {COGNITIVE_ACTIONS_API_KEY}",
"Content-Type": "application/json",
# Add any other required headers for the Cognitive Actions API
}
# Prepare the request body for the hypothetical execution endpoint
request_body = {
"action_id": action_id,
"inputs": payload
}
print(f"--- Calling Cognitive Action: {action.name or action_id} ---")
print(f"Endpoint: {COGNITIVE_ACTIONS_EXECUTE_URL}")
print(f"Action ID: {action_id}")
print("Payload being sent:")
print(json.dumps(request_body, indent=2))
print("------------------------------------------------")
try:
response = requests.post(
COGNITIVE_ACTIONS_EXECUTE_URL,
headers=headers,
json=request_body
)
response.raise_for_status() # Raise an exception for bad status codes (4xx or 5xx)
result = response.json()
print("Action executed successfully. Result:")
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 (non-JSON): {e.response.text}")
print("------------------------------------------------")
Conclusion
Gioa's image generation capabilities provide developers with a robust tool for creating custom visuals that cater to diverse needs. By leveraging the "Generate Image with Custom Mask" action, you can streamline your creative processes, whether you're designing marketing materials, generating concept art, or crafting unique social media images. The flexibility in model selection and adjustable parameters allows for a wide range of applications, making Gioa an invaluable asset in your development toolkit. Explore Gioa today to unlock the potential of custom image generation in your projects!