Create Stunning Images with Titan Pilot's Image Generation

In the rapidly evolving world of AI, image generation has become a game-changer for developers looking to enhance their applications. Titan Pilot offers a robust set of Cognitive Actions that empower users to generate high-quality images based on textual prompts. This service not only simplifies the image creation process but also allows for customization in aspect ratios, output formats, and quality levels. Whether you are building a creative tool, an art application, or enhancing existing content with visuals, Titan Pilot provides the flexibility and power you need.
Prerequisites
To get started with Titan Pilot, you will need a Cognitive Actions API key and a basic understanding of making API calls. This setup will enable you to unlock the full potential of the image generation capabilities.
Generate Image with Pilot
The Generate Image with Pilot action is designed to create images based on a specified prompt, allowing for a variety of customization options that cater to different needs. This action is particularly useful for developers who want to automate the generation of unique visuals, saving time and resources while enhancing user engagement.
Input Requirements
The action requires a prompt, which serves as the textual guide for the image generation. Other optional parameters include:
- mask: URI of an image mask for inpainting.
- seed: For reproducible outputs.
- image: Input image URI for image-to-image transformations.
- width and height: Dimensions for custom aspect ratios.
- imageAspectRatio: Predefined or custom aspect ratio settings.
- imageOutputFormat: Choose from formats like webp, jpg, or png.
- outputCount: Number of images to generate (1 to 4).
- inferenceModel: Select between 'dev' for quality or 'schnell' for speed.
Expected Output
The output will be a generated image in the specified format, and it can vary based on the parameters set. For instance, the output might be a link to the generated image, such as:
https://assets.cognitiveactions.com/invocations/2491c513-fd72-4705-82ee-7015b3d14b24/7b3dd910-5917-4da0-a053-b32321f8e95d.webp
Use Cases for this Specific Action
- Content Creation: Automate the generation of images for blogs, social media, or marketing materials, enhancing visual appeal without the need for a graphic designer.
- Game Development: Create unique assets for characters, environments, or items based on specific prompts, allowing for dynamic content generation in games.
- Artistic Projects: Enable artists to explore new visual styles or concepts by generating images based on their ideas, fostering creativity and inspiration.
- E-commerce: Generate product images with varying backgrounds or settings, helping to visualize items in different contexts for better customer 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 = "a52697ec-9316-4761-ae9e-6edebb7e7631" # Action ID for: Generate Image with Pilot
# Construct the exact input payload based on the action's requirements
# This example uses the predefined example_input for this action:
payload = {
"prompt": "PILOT is eating noodles",
"outputCount": 1,
"guidanceScale": 3.5,
"inferenceModel": "dev",
"promptStrength": 0.8,
"imageAspectRatio": "1:1",
"imageOutputFormat": "webp",
"mainLoraIntensity": 1,
"imageOutputQuality": 90,
"inferenceStepCount": 28,
"additionalLoraIntensity": 1
}
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
Titan Pilot's image generation capabilities provide an invaluable resource for developers aiming to integrate dynamic visual content into their applications. With the ability to customize images based on textual prompts and various parameters, the possibilities are endless. Whether you are looking to enhance user experience, streamline content creation, or explore artistic avenues, Titan Pilot's Generate Image with Pilot action is a powerful tool at your disposal. Start leveraging these capabilities today to elevate your projects to new heights.