Generate Stunning Custom Images with gjiang4/teachergarybeta Cognitive Actions

24 Apr 2025
Generate Stunning Custom Images with gjiang4/teachergarybeta Cognitive Actions

In today's digital landscape, creating unique and high-quality images is crucial for engaging applications. The gjiang4/teachergarybeta API offers a powerful set of Cognitive Actions that leverage artificial intelligence to generate custom images tailored to your specifications. These actions allow developers to create stunning visuals through features like image transformation, inpainting, and fine-tuning of output properties such as resolution and aspect ratio. By utilizing these pre-built actions, developers can save time and enhance the visual appeal of their applications without the need for extensive graphic design skills.

Prerequisites

Before diving into the integration of the Cognitive Actions, ensure you have the following:

  • An API key for accessing the Cognitive Actions platform.
  • Basic understanding of JSON format and RESTful APIs.
  • Familiarity with Python for executing the API calls.

For authentication, you will typically pass your API key in the request headers, ensuring secure access to the actions.

Cognitive Actions Overview

Generate Custom Images

The Generate Custom Images action allows you to create customized images using AI, with options for image transformation and inpainting. This action supports various parameters to control the output, including the model version, image dimensions, and quality settings.

Input

The input for the Generate Custom Images action is structured as follows:

  • Required Fields:
    • prompt: A string that describes the desired image.
  • Optional Fields:
    • mask: (URI) Image mask for inpainting.
    • seed: (integer) Seed for reproducible results.
    • image: (URI) Input image for transformation.
    • model: (string) Select model version (dev or schnell).
    • width: (integer) Width of the image.
    • height: (integer) Height of the image.
    • fastMode: (boolean) Toggle for optimized speed.
    • megapixels: (string) Approximate megapixels.
    • aspectRatio: (string) Aspect ratio of the image.
    • imageQuality: (integer) Output image quality (0-100).
    • outputFormat: (string) Format of the output image.
    • customWeights: (string) Loads LoRA weights.
    • loraIntensity: (number) Controls LoRA intensity.
    • additionalLora: (string) Loads secondary LoRA weights.
    • inferenceSteps: (integer) Number of denoising steps.
    • numberOfOutputs: (integer) Number of images to generate.
    • promptIntensity: (number) Influence of the prompt.
    • guidanceIntensity: (number) Guidance scale.
    • safetyCheckerDisabled: (boolean) Enable/disable safety checker.
    • additionalLoraIntensity: (number) Strength of additional LoRA.

Example Input:

{
  "model": "dev",
  "prompt": "A cinematic full-body portrait of teachergary69 standing confidently on a luxurious rooftop terrace with a breathtaking view of Oriental Pearl TV Tower glowing in the night.\nHe is wearing a perfectly tailored navy blue suit with a modern, slightly oversized fit, layered over a sleek black turtleneck, paired with a designer statement ring and an elegant wristwatch.\nHis hairstyle is styled in a refined yet slightly tousled way, exuding a charismatic K-POP idol aura. His sharp jawline, smooth skin, broad shoulders, strong muscles and piercing gaze enhance the star-like presence.\nThe illuminated Oriental Pearl TV Tower casts a warm, golden glow on the scene, contrasting with the cool-toned cityscape and luxury rooftop ambiance.\nA soft evening breeze moves through his hair as he gazes toward the horizon with effortless confidence, exuding both mystery and charm.\nSubtle, moody lighting highlights his facial structure, adding a cinematic K-POP photoshoot aesthetic.\nShot on a Leica camera, ultra-high-resolution, realistic lighting, and cinematic depth of field.\nSlightly low-angle shot for a powerful, authoritative presence with an idol-like aura.\n",
  "fastMode": false,
  "megapixels": "1",
  "aspectRatio": "16:9",
  "imageQuality": 100,
  "outputFormat": "png",
  "loraIntensity": 1,
  "inferenceSteps": 28,
  "numberOfOutputs": 4,
  "promptIntensity": 0.8,
  "guidanceIntensity": 2,
  "additionalLoraIntensity": 1
}

Output

The output consists of an array of image URLs representing the generated images based on the provided prompt and parameters.

Example Output:

[
  "https://assets.cognitiveactions.com/invocations/bab00b79-24ff-4639-ac4f-5e1ee88014f2/7983469c-1059-4bff-8cfa-1ba4fb8fe7a5.png",
  "https://assets.cognitiveactions.com/invocations/bab00b79-24ff-4639-ac4f-5e1ee88014f2/73064e55-1148-4be3-abb1-c41d5925a8ab.png",
  "https://assets.cognitiveactions.com/invocations/bab00b79-24ff-4639-ac4f-5e1ee88014f2/d9a44164-53a1-441f-8a5b-9081634e3c9d.png",
  "https://assets.cognitiveactions.com/invocations/bab00b79-24ff-4639-ac4f-5e1ee88014f2/9a3d5c79-ea13-4068-8be4-c2cb6e7f9b54.png"
]

Conceptual Usage Example (Python)

Here is a conceptual example of how you might call the Generate Custom Images 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 = "82e48a81-b6ce-4f61-b41b-59f3a10993af" # Action ID for Generate Custom Images

# Construct the input payload based on the action's requirements
payload = {
    "model": "dev",
    "prompt": "A cinematic full-body portrait of teachergary69 standing confidently on a luxurious rooftop terrace with a breathtaking view of Oriental Pearl TV Tower glowing in the night.\nHe is wearing a perfectly tailored navy blue suit...",
    "fastMode": False,
    "megapixels": "1",
    "aspectRatio": "16:9",
    "imageQuality": 100,
    "outputFormat": "png",
    "loraIntensity": 1,
    "inferenceSteps": 28,
    "numberOfOutputs": 4,
    "promptIntensity": 0.8,
    "guidanceIntensity": 2,
    "additionalLoraIntensity": 1
}

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 based on the required input fields, and the action ID corresponds to the Generate Custom Images action. The response will include the URLs of the generated images.

Conclusion

The gjiang4/teachergarybeta Cognitive Actions provide a powerful toolset for developers looking to enhance their applications with custom image generation capabilities. By leveraging the ability to fine-tune image properties and create visually appealing content, you can significantly enrich user experiences. Explore these actions further to uncover potential use cases and maximize the impact of your applications!