Create Stunning Custom Images with Merlin Bob

25 Apr 2025
Create Stunning Custom Images with Merlin Bob

In the world of digital content creation, the ability to generate high-quality images quickly and efficiently can set your project apart. With Merlin Bob's Cognitive Actions, developers can leverage powerful image generation capabilities to produce custom images tailored to their specific needs. This service enables users to create stunning visuals through inpainting techniques, harnessing customizable parameters such as image size, format, and model selection. Whether you’re in graphic design, marketing, or content creation, the benefits of using Merlin Bob are significant—speed, versatility, and creativity are at your fingertips.

Common use cases for Merlin Bob include generating promotional images for social media, creating unique artwork for blogs, or even designing custom assets for games. By using this service, developers can automate and enhance their image production workflows, allowing for rapid iterations and creativity that meets the demands of today’s fast-paced digital landscape.

Prerequisites

To get started with Merlin Bob, you will need a Cognitive Actions API key and a basic understanding of making API calls.

Generate Custom Images with Inpainting

The Generate Custom Images with Inpainting action allows you to produce high-quality images through transformation or inpainting. This action is particularly useful for developers who need to create images based on specific prompts or modify existing images seamlessly.

Purpose

The action focuses on solving the challenge of custom image generation by allowing users to specify parameters like image masks, sizes, and guidance scales. This flexibility enables the creation of visually appealing and contextually relevant images that align with the user's vision.

Input Requirements

The input for this action requires a structured request that includes:

  • prompt (string): A text prompt guiding the image generation, such as "an image of BOB from beetlejuice, in a bright yellow suit, running down a manhattan street."
  • Additionally, parameters like mask, image, width, height, model, outputsCount, and others can be specified to customize the output further.

Expected Output

The output will be a URL pointing to the generated image, which can be directly accessed or used in your application. For example, you might receive an output like:

  • https://assets.cognitiveactions.com/invocations/22c735d4-6c69-4fbe-8867-f6799cc134ca/2bbe5a2c-4af4-48d7-a508-1fbdb6fe178e.webp

Use Cases for this Action

This action is ideal for scenarios where:

  • You want to create tailored images for marketing campaigns that require specific themes or styles.
  • You need to modify existing images or fill in gaps in images with contextually relevant visuals.
  • You are developing an application that requires dynamic image generation based on user inputs or interactions.

By utilizing this action, developers can enhance user engagement and create visually compelling content that resonates with their audience.

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 = "e1290960-7405-4f7a-8107-2f42d510a79c" # 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 = {
  "model": "dev",
  "prompt": "an image of BOB from beetlejuice, in a bright yellow suit, running down a manhattan street",
  "outputsCount": 1,
  "guidanceScale": 3.5,
  "mainLoraScale": 1,
  "outputQuality": 90,
  "promptStrength": 0.8,
  "imageAspectRatio": "1:1",
  "imageOutputFormat": "webp",
  "additionalLoraScale": 1,
  "inferenceStepsCount": 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

Merlin Bob’s Cognitive Actions provide a robust solution for generating custom images, making it an invaluable tool for developers in various industries. By harnessing the power of inpainting and customizable parameters, you can streamline your image creation processes, enhance your digital content, and ultimately elevate your projects. As the demand for quality visual content continues to grow, integrating these capabilities into your applications will keep you ahead of the curve. Start experimenting with Merlin Bob today and unlock the potential of your creative ideas!