Create Unique Images Effortlessly with Thejanae's Image Generation Action

27 Apr 2025
Create Unique Images Effortlessly with Thejanae's Image Generation Action

In today's digital landscape, the ability to generate custom images on demand can significantly enhance user engagement and content creation. Thejanae provides a powerful Cognitive Action that allows developers to create unique images using image-to-image conversion or inpainting modes. This action offers a range of customizable parameters, enabling you to optimize image generation for speed or quality. Whether you are developing a creative application, enhancing a website, or generating assets for social media, Thejanae simplifies the process of image creation while ensuring high-quality outputs.

Prerequisites

To get started with Thejanae's Image Generation Action, you'll need a Cognitive Actions API key and a basic understanding of making API calls.

Generate Custom Image

The Generate Custom Image action empowers developers to create custom images tailored to their specific needs. This action solves the problem of generating unique visual content efficiently, allowing for both creativity and precision in the output.

Input Requirements

To use this action, you need to provide a structured input that includes a text prompt, which serves as the basis for the image generation. Additional parameters such as masks, aspect ratios, dimensions, and various model options can be specified to fine-tune the results. Here’s a brief overview of the required and optional inputs:

  • Prompt (required): The text description of the desired image (e.g., "janae headshot sitting on a white box").
  • Model (optional): Choose between "dev" for detailed outputs or "schnell" for faster generation.
  • Mask (optional): An image mask for inpainting mode.
  • Width & Height (optional): Specify dimensions if using a custom aspect ratio.
  • Output Count (optional): Number of images to generate (1-4).
  • Image Output Format (optional): Choose from webp, jpg, or png.
  • Inference Steps (optional): Set the number of denoising steps (1-50).

Expected Output

The action returns a generated image based on the provided prompt and parameters. The output is a URL link to the generated image, which can be used directly in applications or websites.

Example Output:

  • Generated Image

Use Cases for this Action

  1. Content Creation: Automate the generation of images for blog posts, articles, or social media campaigns, saving time and resources while ensuring unique visuals.
  2. E-commerce: Create product images or mock-ups tailored to specific requirements, enhancing the shopping experience for customers.
  3. Gaming and Virtual Reality: Generate character designs, landscapes, or assets that are integral to game development, providing a creative edge.
  4. Personalization: Utilize user inputs to create customized images that cater to individual preferences, enhancing user engagement and satisfaction.
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 = "5e6fa3a0-8280-45ad-99ff-97097b710beb" # 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 = {
  "model": "dev",
  "prompt": "janae headshot sitting on a white box",
  "outputCount": 1,
  "loraWeightScale": 1,
  "approxMegapixels": "1",
  "imageAspectRatio": "3:4",
  "imageOutputFormat": "webp",
  "imageOutputQuality": 80,
  "inferenceStepCount": 32,
  "accelerateInference": false,
  "additionalLoraScale": 1,
  "imagePromptStrength": 0.96,
  "diffusionGuidanceScale": 2.18
}

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

Thejanae's Generate Custom Image action offers a robust solution for developers looking to enhance their applications with unique visual content. By leveraging customizable parameters, you can optimize image generation for both speed and quality, making it easier than ever to create tailored images for various use cases. Explore the possibilities of integrating this action into your projects to unlock new levels of creativity and efficiency.