Create Customizable Rubber Duck Images with the publu/rubberducky Cognitive Actions

24 Apr 2025
Create Customizable Rubber Duck Images with the publu/rubberducky Cognitive Actions

Integrating AI-driven image generation into your applications has never been easier with the publu/rubberducky Cognitive Actions. Specifically designed for developers, this API allows you to generate customizable images of rubber ducks, which can be tailored to your unique creative vision. By leveraging pre-built actions, you can save time and effort while adding engaging visuals to your projects.

Prerequisites

To get started with the publu/rubberducky Cognitive Actions, you'll need an API key from the Cognitive Actions platform. This key will authenticate your requests and ensure you have access to the image generation capabilities. Typically, the API key is sent in the headers of your requests, allowing for secure and streamlined interactions with the service.

Cognitive Actions Overview

Generate Rubber Duck Images

The Generate Rubber Duck Images action allows you to create various images of rubber ducks based on customizable parameters. You can specify the output size, the number of images, and even the artistic style of the generated image.

Input

The input for this action requires a JSON object with the following fields:

  • seed (optional): Random seed for reproducible results. If left blank, a random seed is used.
  • image (optional): A starting image for generating variations. Dimensions of the output will match this input image.
  • width (optional): Width of the output image (default is 512, maximum is 1024).
  • height (optional): Height of the output image (default is 512, maximum is 1024).
  • prompt (required): The main description for the image. Default is "a photo of a rubber duck ducky".
  • scheduler (optional): The algorithm for the diffusion process (default is "DDIM").
  • guidanceScale (optional): Scale factor for classifier-free guidance (default is 7.5).
  • negativePrompt (optional): Elements to avoid in the image.
  • promptStrength (optional): Strength of the prompt when using an initial image (default is 0.8).
  • numberOfOutputs (optional): How many images to generate (default is 1, maximum is 4).
  • disableSafetyCheck (optional): Option to bypass safety checks (default is false).
  • numberOfInferenceSteps (optional): Number of denoising steps (default is 50, maximum is 500).

Example Input:

{
  "width": 512,
  "height": 512,
  "prompt": "a photo of a rubber duck ducky, cartoon, baking hat",
  "scheduler": "DDIM",
  "guidanceScale": 7.5,
  "promptStrength": 0.8,
  "numberOfOutputs": 1,
  "numberOfInferenceSteps": 50
}

Output

Upon successfully executing the action, you will receive an array of image URLs. Each URL points to a generated rubber duck image, ready for use in your application.

Example Output:

[
  "https://assets.cognitiveactions.com/invocations/b825d1f1-f1d1-4fc8-ba60-46e54379e290/c29f9b04-e372-4b0f-a328-b9ff193b5b38.png"
]

Conceptual Usage Example (Python)

Here’s how a developer might call this action using Python. This example illustrates how to structure the input JSON payload correctly while interacting with a hypothetical Cognitive Actions execution endpoint.

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 = "2da957ee-57d6-4c67-8482-e3919804629a"  # Action ID for Generate Rubber Duck Images

# Construct the input payload based on the action's requirements
payload = {
    "width": 512,
    "height": 512,
    "prompt": "a photo of a rubber duck ducky, cartoon, baking hat",
    "scheduler": "DDIM",
    "guidanceScale": 7.5,
    "promptStrength": 0.8,
    "numberOfOutputs": 1,
    "numberOfInferenceSteps": 50
}

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, replace YOUR_COGNITIVE_ACTIONS_API_KEY with your actual API key. The action_id variable is set to match the Generate Rubber Duck Images action ID. The input payload is constructed based on the action's schema, ensuring that the request sent to the API is properly formatted.

Conclusion

The publu/rubberducky Cognitive Actions provide a fun and creative way to generate rubber duck images tailored to your specifications. By leveraging these pre-built actions, developers can enhance their applications with engaging visual content, saving time and resources. Whether you’re looking to add whimsy to a project or create unique art, these actions open up a world of possibilities. Start experimenting today, and let your creativity flow!