Unlocking Creative Potential: Using Image Generation with Cognitive Actions

22 Apr 2025
Unlocking Creative Potential: Using Image Generation with Cognitive Actions

In today's digital landscape, the ability to generate and manipulate images using AI is a game-changer for developers and creatives alike. The joanafeitoza/juliabeatriz API provides powerful Cognitive Actions that allow you to generate images through innovative techniques such as inpainting and image-to-image transformations. This blog post will guide you through the capabilities of these actions, focusing on the Generate Image with Inpainting action, which offers a range of customization options to suit your creative needs.

Prerequisites

To get started with the Cognitive Actions from the joanafeitoza/juliabeatriz API, you will need:

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

Authentication is typically handled by passing your API key in the headers of your requests, ensuring secure access to the API's functionalities.

Cognitive Actions Overview

Generate Image with Inpainting

The Generate Image with Inpainting action enables developers to create images by using inpainting techniques or transforming existing images. This action supports various parameters, giving you control over aspects like resolution, aspect ratio, and the number of outputs. It’s designed to enhance creativity while allowing for rapid image generation.

Input

The input for this action is a structured JSON object that requires a prompt and offers a range of optional fields to customize the image generation process. Below is a breakdown of the input schema along with an example:

{
  "image": "https://replicate.delivery/pbxt/MmcqARgXpfKq4N0jC9brJI8IQW6OEmlatZiY1VXCmL8keDzz/image%2057.png",
  "model": "dev",
  "prompt": "juliabeatriz ",
  "megapixels": "1",
  "aspectRatio": "4:5",
  "imageFormat": "png",
  "outputCount": 3,
  "imageQuality": 100,
  "loraIntensity": 1,
  "influenceLevel": 2,
  "promptIntensity": 0.8,
  "inferenceStepCount": 28,
  "accelerateProcessing": false,
  "additionalLoraIntensity": 1
}

Key Fields:

  • prompt (required): A textual prompt guiding the image generation.
  • image (optional): URI of an input image for transformation.
  • model (optional): Specifies the model to be used for inference.
  • aspectRatio (optional): Defines the aspect ratio of the output image.
  • outputCount (optional): Number of images to generate (1-4).

Output

The output of this action is an array of URLs pointing to the generated images. Here’s an example of what you can expect:

[
  "https://assets.cognitiveactions.com/invocations/923502f4-6cb4-4e7e-9498-d3229ce15e3d/473b70d8-f787-41a7-9929-136272c62f90.png",
  "https://assets.cognitiveactions.com/invocations/923502f4-6cb4-4e7e-9498-d3229ce15e3d/05ecbe34-dae5-413b-9f02-482d1b0146b3.png",
  "https://assets.cognitiveactions.com/invocations/923502f4-6cb4-4e7e-9498-d3229ce15e3d/6a08e771-83e1-4f50-8422-964cfed716d1.png"
]

This array contains the URLs for each generated image, allowing easy access to the results of your request.

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 = "819383e2-8486-483e-94ab-261fffe75f28"  # Action ID for Generate Image with Inpainting

# Construct the input payload based on the action's requirements
payload = {
    "image": "https://replicate.delivery/pbxt/MmcqARgXpfKq4N0jC9brJI8IQW6OEmlatZiY1VXCmL8keDzz/image%2057.png",
    "model": "dev",
    "prompt": "juliabeatriz ",
    "megapixels": "1",
    "aspectRatio": "4:5",
    "imageFormat": "png",
    "outputCount": 3,
    "imageQuality": 100,
    "loraIntensity": 1,
    "influenceLevel": 2,
    "promptIntensity": 0.8,
    "inferenceStepCount": 28,
    "accelerateProcessing": False,
    "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 structured according to the action's input requirements, demonstrating how to effectively utilize the API.

Conclusion

The Generate Image with Inpainting action from the joanafeitoza/juliabeatriz API empowers developers to create stunning images with ease. By leveraging the flexibility of input parameters, you can customize your image generation process to suit a wide array of applications, whether for creative projects, content generation, or more.

As you explore this powerful tool, consider experimenting with different prompts, models, and image settings to discover the full potential of your creativity. Happy coding!