Create Stunning Custom Images with Thelion's Cognitive Actions

25 Apr 2025
Create Stunning Custom Images with Thelion's Cognitive Actions

Thelion is a powerful AI-based image generation service designed to simplify the process of creating custom images tailored to your specific needs. With its advanced Cognitive Actions, developers can leverage the capabilities of Thelion to generate high-quality images based on user-defined prompts, images, and various customization parameters. The benefits of using Thelion include rapid image generation, flexibility in design, and the ability to produce unique visuals that can enhance applications, marketing materials, and creative projects.

Imagine needing to create a unique character for a game or an engaging illustration for a blog post. Thelion's image generation capabilities allow you to transform your ideas into visually striking images with just a few parameters. From artists to developers, anyone looking to create custom visuals can find immense value in integrating Thelion's Cognitive Actions into their workflow.

Prerequisites

To get started with Thelion, you'll need a Cognitive Actions API key and a basic understanding of API calls to harness the full potential of its features.

Generate Custom Image

The "Generate Custom Image" action allows users to create custom images by providing input images or masks. This action supports a range of customization options, including aspect ratio, resolution, and output format. Enhanced by LoRA and replicate model weights, this action ensures high-quality results tailored to your specifications.

Input Requirements:

  • prompt: A descriptive string that guides the image generation process.
  • image: (Optional) An input image for transformation or inpainting.
  • mask: (Optional) An image mask for inpainting mode.
  • width and height: (Optional) Custom dimensions for the generated image.
  • numOutputs: Specifies how many images to generate.
  • outputQuality: Determines the quality of the output images.

Expected Output: A URL link to the generated image in the specified format.

Use Cases for this specific action:

  • Creative Projects: Artists and designers can use Thelion to generate unique artwork based on their concepts, saving time and enhancing creativity.
  • Marketing Materials: Businesses can quickly create custom images for social media, ads, or websites, ensuring they have unique visuals that stand out.
  • Gaming: Developers can generate characters or environments, streamlining the design process and allowing for rapid iterations.

```python
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 = "600b45af-50d4-4034-9cea-5d59c6f8d951" # Action ID for: Generate Custom Image

# Construct the exact input payload based on the action's requirements
# This example uses the predefined example_input for this action:
payload = {
  "width": 825,
  "goFast": false,
  "height": 819,
  "prompt": "A cartoon-style 2D lion. The little lion is in the middle of the tall grass of the savanna that covers half his body. The lion is in profile looking to the right among the grass. The lion looks very far away, allowing the landscape of tall grass to be seen much more.",
  "loraScale": 1,
  "numOutputs": 1,
  "guidanceScale": 3,
  "outputQuality": 80,
  "extraLoraScale": 1,
  "inferenceModel": "dev",
  "promptStrength": 0.52,
  "imageMegapixels": "1",
  "imageAspectRatio": "1:1",
  "imageOutputFormat": "webp",
  "numInferenceSteps": 28
}

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
Thelion's Cognitive Actions, especially the "Generate Custom Image" function, provide developers with a robust toolset for creating tailored images that cater to various needs. By integrating this action, users can streamline their image creation process, enhance their creative projects, and deliver unique visuals that resonate with their audience. Whether you are an artist, a marketer, or a game developer, Thelion opens up new possibilities for your image generation endeavors. Start exploring Thelion today to take your creative projects to the next level!