Generate Stunning Images with the sayyourengtutor/dima3 Cognitive Actions

23 Apr 2025
Generate Stunning Images with the sayyourengtutor/dima3 Cognitive Actions

In today's digital landscape, the ability to generate high-quality images on demand can empower developers to enhance their applications significantly. The sayyourengtutor/dima3 API offers a powerful Cognitive Action that allows users to create images using custom prompts and parameters. This feature utilizes advanced models for optimized inference, making it suitable for various applications, from artistic creations to practical implementations like educational tools.

In this blog post, we will explore how to leverage the "Generate Image with Custom Parameters" action, its capabilities, and how to integrate it into your applications seamlessly.

Prerequisites

Before you begin using the Cognitive Actions, ensure you have the following:

  • An API key for the Cognitive Actions platform.
  • Basic familiarity with making HTTP requests and handling JSON data.

Authentication typically involves including your API key in the headers of your requests, allowing secure access to the service.

Cognitive Actions Overview

Generate Image with Custom Parameters

The Generate Image with Custom Parameters action enables developers to create images using custom textual prompts, with options to control various parameters such as aspect ratio, image resolution, and output formats. This action is categorized under image-generation and provides robust capabilities for generating high-quality visuals.

Input

The input for this action is structured as a JSON object. Here are the required and optional fields based on the input schema:

  • Required:
    • prompt: A string that describes the image to be generated. For example:
      "A male tutor working in a bright home office with natural light, bookshelves filled with literature, dressed in a casual pullover, a warm smile."
      
  • Optional:
    • mask: (string) Image mask for inpainting mode.
    • seed: (integer) Random seed for reproducibility.
    • image: (string) Input image for transformations.
    • model: (string) Choose between "dev" and "schnell".
    • width: (integer) Width of the generated image.
    • goFast: (boolean) Enable faster predictions.
    • height: (integer) Height of the generated image.
    • extraLora, loraScale, numOutputs, aspectRatio, outputFormat, guidanceScale, outputQuality, extraLoraScale, promptStrength, imageResolution, numInferenceSteps, disableSafetyChecker: Additional parameters to fine-tune the image generation process.

Example Input:

{
  "model": "dev",
  "goFast": false,
  "prompt": "A male tutor working in a bright home office with natural light, bookshelves filled with literature, dressed in a casual pullover, a warm smile",
  "loraScale": 1,
  "numOutputs": 2,
  "aspectRatio": "1:1",
  "outputFormat": "jpg",
  "guidanceScale": 3.1,
  "outputQuality": 80,
  "extraLoraScale": 1,
  "promptStrength": 0.82,
  "imageResolution": "1",
  "numInferenceSteps": 35
}

Output

Upon successful execution, the action returns a list of URLs pointing to the generated images. Each URL corresponds to an output image based on the specified parameters.

Example Output:

[
  "https://assets.cognitiveactions.com/invocations/da5a3121-5e04-4f84-8995-263b900eabb3/0a99cf1a-21c1-4461-9b40-2666e102b29f.jpg",
  "https://assets.cognitiveactions.com/invocations/da5a3121-5e04-4f84-8995-263b900eabb3/2abcdfd0-2d05-4235-92d9-d669bb077e6f.jpg"
]

Conceptual Usage Example (Python)

Here's a conceptual Python snippet demonstrating how to call the Generate Image with Custom Parameters action using the described input structure:

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 = "93eba484-56bc-46ec-9427-8c94c69279a8"  # Action ID for Generate Image with Custom Parameters

# Construct the input payload based on the action's requirements
payload = {
    "model": "dev",
    "goFast": False,
    "prompt": "A male tutor working in a bright home office with natural light, bookshelves filled with literature, dressed in a casual pullover, a warm smile",
    "loraScale": 1,
    "numOutputs": 2,
    "aspectRatio": "1:1",
    "outputFormat": "jpg",
    "guidanceScale": 3.1,
    "outputQuality": 80,
    "extraLoraScale": 1,
    "promptStrength": 0.82,
    "imageResolution": "1",
    "numInferenceSteps": 35
}

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 code snippet, replace the placeholder API key and endpoint with your actual values. The structured input payload is configured based on the requirements of the action, and the response is handled appropriately.

Conclusion

The Generate Image with Custom Parameters action from the sayyourengtutor/dima3 API provides a versatile tool for generating high-quality images tailored to your specific needs. By understanding how to configure the input parameters and handle the output, developers can seamlessly integrate this functionality into their applications, enhancing user experience and engagement.

Explore the possibilities of image generation and start applying these Cognitive Actions in your projects today!