Create Custom Images Effortlessly with Itay's Inpainting Action

27 Apr 2025
Create Custom Images Effortlessly with Itay's Inpainting Action

In the world of digital content creation, the ability to generate unique and custom images can set your application apart. Itay offers a powerful Cognitive Action that leverages inpainting techniques to create bespoke images tailored to your specifications. This action allows developers to input images and masks while customizing dimensions, quality, and formats, making it a versatile tool for a variety of projects. Whether you're building a game, a marketing campaign, or a creative portfolio, Itay's image generation capabilities can save you time and enhance your visual storytelling.

Imagine being able to generate whimsical illustrations or realistic scenes just by providing a descriptive text prompt. With options to choose between different models for speed and detail, Itay ensures you can optimize the image generation process according to your needs. This flexibility opens up a myriad of use cases, from creating personalized content for social media to designing unique assets for video games or digital art.

Prerequisites

To utilize Itay's Cognitive Actions, you'll need an API key and a basic understanding of how to make API calls. This will allow you to seamlessly integrate the image generation capabilities into your applications.

Generate Custom Images with Inpainting

This action creates custom images utilizing inpainting techniques. It allows specifying input images, image masks, and customization of dimensions, quality, and formats. Users can choose between the 'dev' and 'schnell' models for optimal image generation, adjusting for speed and detail.

Input Requirements

To use this action, you need to provide:

  • prompt: A descriptive text prompt for generating images (required).
  • image: A URI to an input image for image-to-image conversion or inpainting (optional).
  • mask: A URI to an image mask used for inpainting mode (optional).
  • Additional parameters like dimensions, output format, and quality settings.

Expected Output

The action will return a URI to the generated image, which can be directly used in your applications.

Use Cases for this specific action:

  • Creative Projects: Generate unique illustrations for books, games, or marketing materials based on specific prompts.
  • Personalization: Create tailored images for users based on their input or preferences, enhancing user engagement.
  • Rapid Prototyping: Quickly generate visual assets for design mockups or presentations.
import requests
import json

# Replace with your actual Cognitive Actions API key and endpoint
# Ensure your environment securely handles the API key
COGNITIVE_ACTIONS_API_KEY = "YOUR_COGNITIVE_ACTIONS_API_KEY"
# This endpoint URL is hypothetical and should be documented for users
COGNITIVE_ACTIONS_EXECUTE_URL = "https://api.cognitiveactions.com/actions/execute"

action_id = "66cff928-fa93-4c03-be54-c476be2c66b7" # Action ID for: Generate Custom Images with Inpainting

# Construct the exact input payload based on the action's requirements
# This example uses the predefined example_input for this action:
payload = {
  "prompt": "Create a whimsical 3D cartoon-style illustration of Itay, a curious 3-year-old boy with wide eyes and tousled hair, waking up in the middle of the night.  \n\nHe’s holding a soft white blanket, dragging it along as he walks into a cozy, warmly lit living room. His expression is a mix of sleepiness and curiosity, wondering why everyone is still awake.  \n\nThe living room is softly illuminated with warm, ambient lighting, featuring plush furniture, subtle decor, and an inviting atmosphere that captures the tender and magical feel of this moment. ",
  "loraScale": 1,
  "numOutputs": 1,
  "aspectRatio": "1:1",
  "outputFormat": "webp",
  "guidanceScale": 3.5,
  "outputQuality": 90,
  "extraLoraScale": 1,
  "inferenceModel": "dev",
  "promptStrength": 0.8,
  "numInferenceSteps": 28
}

headers = {
    "Authorization": f"Bearer {COGNITIVE_ACTIONS_API_KEY}",
    "Content-Type": "application/json",
    # Add any other required headers for the Cognitive Actions API
}

# Prepare the request body for the hypothetical execution endpoint
request_body = {
    "action_id": action_id,
    "inputs": payload
}

print(f"--- Calling Cognitive Action: {action.name or action_id} ---")
print(f"Endpoint: {COGNITIVE_ACTIONS_EXECUTE_URL}")
print(f"Action ID: {action_id}")
print("Payload being sent:")
print(json.dumps(request_body, indent=2))
print("------------------------------------------------")

try:
    response = requests.post(
        COGNITIVE_ACTIONS_EXECUTE_URL,
        headers=headers,
        json=request_body
    )
    response.raise_for_status() # Raise an exception for bad status codes (4xx or 5xx)

    result = response.json()
    print("Action executed successfully. Result:")
    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 (non-JSON): {e.response.text}")
    print("------------------------------------------------")

Conclusion

Itay's inpainting action provides a robust solution for developers looking to create custom images quickly and efficiently. With its flexibility in input options and output quality, it opens up numerous possibilities for creative expression and personalization in your projects. To get started, integrate the API into your workflow and explore the diverse applications of image generation in your domain. Embrace the power of AI-driven image creation and elevate your content to new heights!