Create Stunning Images with zeyadnader/bodda Cognitive Actions

23 Apr 2025
Create Stunning Images with zeyadnader/bodda Cognitive Actions

In the realm of image generation, the zeyadnader/bodda API offers robust Cognitive Actions that empower developers to create high-quality images with remarkable detail. With features such as customizable prompts, inpainting capabilities, and various output formats, these pre-built actions streamline the process of generating visually appealing content. Whether you’re designing a professional profile picture or producing artwork, the Cognitive Actions available within this API can significantly enhance your application’s capabilities.

Prerequisites

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

  • API Key: You will need an API key to authenticate your requests with the Cognitive Actions platform. This key should be included in the request headers.
  • Setup: Familiarity with making HTTP requests and handling JSON payloads is beneficial for implementing these actions.

Cognitive Actions Overview

Generate Image using Image Inpainting

The Generate Image using Image Inpainting action creates high-quality images using inpainting techniques, enabling developers to produce images based on textual prompts or modify existing images. This action is particularly useful for generating creative visuals tailored to specific requirements.

  • Category: Image Generation

Input

This action accepts a variety of parameters to customize the image generation process. Here’s an overview of the required and optional fields:

  • Required:
    • prompt: (string) A detailed description of the desired image.
  • Optional:
    • mask: (string) URI of the image mask used for inpainting mode.
    • seed: (integer) A random seed for consistency in results.
    • image: (string) Input image for image-to-image or inpainting mode.
    • width: (integer) Width of the generated image (custom aspect ratio).
    • height: (integer) Height of the generated image (custom aspect ratio).
    • goFast: (boolean) Enable faster generation using a speed-optimized model.
    • imageFormat: (string) Specifies the file format for output images (webp, jpg, png).
    • outputCount: (integer) Number of images to generate (1-4).
    • guidanceScale: (number) Controls the guidance strength in the generation process.
    • outputQuality: (integer) Quality setting for the output images.
    • denoisingSteps: (integer) Number of inference steps for detail enhancement.
    • inferenceModel: (string) The model used for inference (dev, schnell).
    • promptStrength: (number) Influence of the prompt in img2img mode.
    • imageMegapixels: (string) Approximate megapixel count of the image.
    • imageAspectRatio: (string) Sets the aspect ratio for the generated image.
    • disableSafetyChecker: (boolean) Disable the safety checker for image generation.

Example Input:

{
  "goFast": false,
  "prompt": "A professional headshot of bodda, a confident individual with a warm, approachable smile, wearing a sharp navy business suit, standing against a clean, softly blurred background with subtle bokeh lights, studio lighting accentuating the face, ultra-realistic details, 4k resolution, perfectly centered, optimized for a LinkedIn profile",
  "loraScale": 1,
  "imageFormat": "webp",
  "outputCount": 1,
  "guidanceScale": 3,
  "outputQuality": 80,
  "denoisingSteps": 28,
  "inferenceModel": "dev",
  "promptStrength": 0.8,
  "imageMegapixels": "1",
  "imageAspectRatio": "1:1",
  "additionalLoraScale": 1
}

Output

The action returns an array of URLs, each pointing to the generated images. Here’s the expected output format:

Example Output:

[
  "https://assets.cognitiveactions.com/invocations/cfa222e5-de8f-41ab-a63d-b11b28c4faa9/32f537a1-bc42-4d7a-807d-decf3b3c86fd.webp"
]

Conceptual Usage Example (Python)

To utilize the Generate Image using Image Inpainting action, you can structure your API call as follows:

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 = "c89d7a47-7396-418a-a2e8-6e45acf7fbd1"  # Action ID for Generate Image using Image Inpainting

# Construct the input payload based on the action's requirements
payload = {
    "goFast": False,
    "prompt": "A professional headshot of bodda, a confident individual with a warm, approachable smile, wearing a sharp navy business suit, standing against a clean, softly blurred background with subtle bokeh lights, studio lighting accentuating the face, ultra-realistic details, 4k resolution, perfectly centered, optimized for a LinkedIn profile",
    "loraScale": 1,
    "imageFormat": "webp",
    "outputCount": 1,
    "guidanceScale": 3,
    "outputQuality": 80,
    "denoisingSteps": 28,
    "inferenceModel": "dev",
    "promptStrength": 0.8,
    "imageMegapixels": "1",
    "imageAspectRatio": "1:1",
    "additionalLoraScale": 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 Python code snippet, replace the COGNITIVE_ACTIONS_API_KEY with your actual API key. The action ID for Generate Image using Image Inpainting is included, and the input payload is structured based on the example provided. The endpoint URL and request structure are illustrative and should be adapted based on your specific integration needs.

Conclusion

The zeyadnader/bodda Cognitive Actions offer powerful tools for developers aiming to enhance their applications with high-quality image generation capabilities. By leveraging the customizable options available in these actions, you can create stunning visuals tailored to your specific needs. Start integrating today and unlock the potential of automated image generation!