Create Stunning Images with the stoodioai/forsberg-don Cognitive Actions

25 Apr 2025
Create Stunning Images with the stoodioai/forsberg-don Cognitive Actions

In the realm of image generation, the stoodioai/forsberg-don API provides powerful Cognitive Actions designed for developers looking to enhance their applications with advanced image creation capabilities. One of the key actions available is Generate Image with Inpainting, which allows you to create intricate images using various specifications such as aspect ratios, image dimensions, and output formats. Utilizing these pre-built actions can save time and effort, enabling you to focus on developing innovative features for your applications.

Prerequisites

To get started with the Cognitive Actions, you'll need an API key for the Cognitive Actions platform. This key is essential for authentication and should be passed in the request headers. Ensure that you have proper access to the API and familiarize yourself with the required parameters for the actions you wish to implement.

Cognitive Actions Overview

Generate Image with Inpainting

The Generate Image with Inpainting action enables the creation of detailed images through image-to-image transformations or inpainting. You can specify various parameters to customize the output, including aspect ratios, dimensions, and artistic styles.

Input

The input schema for this action requires the following fields:

  • prompt (required): A descriptive text prompt for image generation. For example:
    "prompt": "forsberg-don, upper body shot, wearing a tshirt, looking straight in the camera, ecommerce photography, white background"
    
  • mask (optional): A URI for the image mask used in inpainting mode.
  • seed (optional): An integer seed for reproducibility.
  • image (optional): A URI of the input image for transformations.
  • width (optional): An integer for the width of the generated image (256 to 1440).
  • height (optional): An integer for the height of the generated image (256 to 1440).
  • outputCount (optional): Specifies the number of images to generate (1 to 4).
  • mainLoraScale (optional): Sets the intensity for applying the main LoRA (default is 1).
  • outputQuality (optional): Defines the quality level of output images (0 to 100).
  • denoisingSteps (optional): Number of steps for enhancing image details (1 to 50).
  • inferenceModel (optional): Specifies the model for inference, either "dev" or "schnell".
  • promptStrength (optional): Influences the retention of the originating image data (0 to 1).
  • imageMegapixels (optional): Estimated number of megapixels for the generated image.
  • imageAspectRatio (optional): Specifies the aspect ratio for the generated image.
  • optimizeForSpeed (optional): Enables faster image generation.
  • imageOutputFormat (optional): Defines the format of the output images (webp, jpg, png).
  • additionalLoraScale and additionalLoraWeights (optional): For loading additional LoRA weights.
  • safetyCheckerDisabled (optional): Bypass the safety checker for generated images.
  • diffusionGuidanceScale (optional): Guidance scale for the diffusion process (0 to 10).

Example Input:

{
  "prompt": "forsberg-don, upper body shot, wearing a tshirt, looking straight in the camera, ecommerce photography, white background",
  "outputCount": 1,
  "mainLoraScale": 1,
  "outputQuality": 80,
  "denoisingSteps": 30,
  "inferenceModel": "dev",
  "promptStrength": 0.8,
  "imageMegapixels": "1",
  "imageAspectRatio": "3:4",
  "optimizeForSpeed": false,
  "imageOutputFormat": "webp",
  "additionalLoraScale": 1,
  "diffusionGuidanceScale": 3
}

Output

The output of this action is typically a URL link to the generated image. Here’s an example of what you might receive as output:

[
  "https://assets.cognitiveactions.com/invocations/4d81695a-374f-4dab-ac23-454777356e7e/7610033f-6f0f-4a6b-bd98-ebac439e0799.webp"
]

This URL can be used to access the generated image directly.

Conceptual Usage Example (Python)

Here’s a conceptual example of how you might call the Generate Image with Inpainting 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 = "552dc1d5-3514-46a8-a8b4-1ba2f9c9162f" # Action ID for Generate Image with Inpainting

# Construct the input payload based on the action's requirements
payload = {
    "prompt": "forsberg-don, upper body shot, wearing a tshirt, looking straight in the camera, ecommerce photography, white background",
    "outputCount": 1,
    "mainLoraScale": 1,
    "outputQuality": 80,
    "denoisingSteps": 30,
    "inferenceModel": "dev",
    "promptStrength": 0.8,
    "imageMegapixels": "1",
    "imageAspectRatio": "3:4",
    "optimizeForSpeed": False,
    "imageOutputFormat": "webp",
    "additionalLoraScale": 1,
    "diffusionGuidanceScale": 3
}

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, you replace your API key and specify the appropriate endpoint. The input payload is structured according to the action's requirements, including the prompt and other parameters. The response contains the generated image URL, which you can use in your application.

Conclusion

The stoodioai/forsberg-don Cognitive Actions, particularly the Generate Image with Inpainting, offer developers a robust way to create stunning images tailored to their specific needs. By integrating these actions, you can significantly enhance the visual capabilities of your applications, making them more engaging and visually appealing. Explore the possibilities and take your image generation to the next level!