Generate Stunning Images with the titouv/test_model3 Cognitive Actions

23 Apr 2025
Generate Stunning Images with the titouv/test_model3 Cognitive Actions

In the realm of digital creativity, the titouv/test_model3 API provides powerful Cognitive Actions that enable developers to generate high-quality images from text prompts. With features like image inpainting, customizable parameters, and optimized processing speed, this API is a fantastic tool for applications ranging from content creation to artistic endeavors. By leveraging these pre-built actions, developers can streamline their workflows and enhance user experiences with stunning visual outputs.

Prerequisites

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

  • API Key: You will need an API key for the Cognitive Actions platform to authenticate your requests. This API key should be included in the request headers.
  • Environment Setup: Make sure you have Python installed, along with the requests library for handling HTTP requests.

Authentication is generally handled by passing the API key in the headers of your requests, allowing you to securely access the Cognitive Actions.

Cognitive Actions Overview

Generate Image with Inpainting

Description: This action allows you to generate an image based on a text prompt. It supports image inpainting, enabling developers to customize various parameters such as image size, aspect ratio, output format, and quality. The model emphasizes fast and high-quality generation, optimizing the process for speed and detailed output.

Category: Image Generation

Input

The input schema for this action requires the following fields:

  • prompt (required): A detailed description of what you want the image to depict.
  • mask (optional): An image mask for inpainting mode.
  • seed (optional): A random seed for reproducible generation.
  • image (optional): An input image for image-to-image or inpainting mode.
  • model (optional): Select the model for inference (default is "dev").
  • width (optional): Width of the generated image (applicable when using a custom aspect ratio).
  • height (optional): Height of the generated image (applicable when using a custom aspect ratio).
  • fastMode (optional): Enable to accelerate predictions.
  • megapixels (optional): Specify the approximate number of megapixels.
  • imageFormat (optional): Format of the output images (default is "webp").
  • outputCount (optional): Number of outputs to generate (default is 1).
  • imageQuality (optional): Quality of the output images (default is 80).
  • loadedWeights (optional): Load LoRA weights from supported models.
  • loraIntensity (optional): Determines how strongly the main LoRA should be applied.
  • inferenceSteps (optional): Number of denoising steps for more detailed images.
  • promptInfluence (optional): Prompt strength when using img2img.
  • imageAspectRatio (optional): Select the aspect ratio for the generated image (default is "1:1").
  • diffusionGuidance (optional): Guidance scale for the diffusion process.
  • safetyCheckerDisabled (optional): Option to disable the safety checker.
  • additionalLora (optional): Load additional LoRA weights.
  • additionalLoraIntensity (optional): Determines how strongly the extra LoRA should be applied.

Example Input:

{
  "seed": 47371,
  "model": "dev",
  "prompt": "resume picture of titouan, young man 20 years old with short brown hair. He is smiling and looking at the camera. The photo is taken in a studio setting, with a white background and soft lighting. The composition is dynamic and the subject is well-dressed, conveying a sense of professionalism and confidence.",
  "imageFormat": "webp",
  "outputCount": 1,
  "imageQuality": 80,
  "loraIntensity": 1,
  "inferenceSteps": 28,
  "imageAspectRatio": "1:1",
  "diffusionGuidance": 3.5
}

Output

The action typically returns an array of URLs pointing to the generated images. For example:

Example Output:

[
  "https://assets.cognitiveactions.com/invocations/15e19984-d7f9-4f5b-8786-87355c1e9373/6810ff40-1286-45d6-80ff-3df59e1bd60f.webp"
]

Conceptual Usage Example (Python)

Here's a conceptual Python code snippet that demonstrates how to call the Cognitive Actions execution endpoint:

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 = "fa8189ec-6f92-487d-96df-8de43d1e240a" # Action ID for Generate Image with Inpainting

# Construct the input payload based on the action's requirements
payload = {
    "seed": 47371,
    "model": "dev",
    "prompt": "resume picture of titouan, young man 20 years old with short brown hair. He is smiling and looking at the camera. The photo is taken in a studio setting, with a white background and soft lighting. The composition is dynamic and the subject is well-dressed, conveying a sense of professionalism and confidence.",
    "imageFormat": "webp",
    "outputCount": 1,
    "imageQuality": 80,
    "loraIntensity": 1,
    "inferenceSteps": 28,
    "imageAspectRatio": "1:1",
    "diffusionGuidance": 3.5
}

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 snippet, replace YOUR_COGNITIVE_ACTIONS_API_KEY with your actual API key. The payload is structured to match the input schema required by the "Generate Image with Inpainting" action, and the output will be printed to the console.

Conclusion

The titouv/test_model3 Cognitive Actions provide an efficient and powerful way to generate images from text prompts. With capabilities for customization and rapid generation, these actions can significantly enhance your applications. Whether you're developing content for social media, websites, or creative projects, integrating these cognitive actions opens up a world of possibilities. Start experimenting today and unlock the full potential of image generation!