Generate Stunning Image Variations with crdbello/1st Cognitive Actions

21 Apr 2025
Generate Stunning Image Variations with crdbello/1st Cognitive Actions

In the world of digital creativity, having the right tools can make all the difference. The crdbello/1st API provides a powerful Cognitive Action that allows developers to generate customized image variations based on a provided image URI and specific prompts. This capability can greatly enhance applications that require dynamic visual content, whether for marketing, design, or personal projects. With the ability to produce multiple variations in a single request, developers can easily explore creative directions and improve user engagement.

Prerequisites

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

  • An API key for the Cognitive Actions platform, which will be required for authentication.
  • Familiarity with making HTTP requests and handling JSON data in your development environment.

Authentication typically involves passing the API key in the request headers, allowing you to securely access the Cognitive Actions.

Cognitive Actions Overview

Generate Image Variations

The Generate Image Variations action allows you to create multiple customized variations of an image based on specific characteristics. By utilizing a provided image URI and detailed prompts, this action enables the generation of up to four unique image outputs per request.

Input

The input for this action requires a JSON object adhering to the following schema:

{
  "image": "https://replicate.delivery/pbxt/LsHQZEKjufoB7rxwbmLYrr9Cn4IdzWIDBuxI8rtyHDKQNVAq/bedroom.jpg",
  "prompt": "a bedroom",
  "guidanceScale": 15,
  "negativePrompt": "lowres, watermark, banner, logo, watermark, contactinfo, text, deformed, blurry, blur, out of focus, out of frame, surreal, extra, ugly, upholstered walls, fabric walls, plush walls, mirror, mirrored, functional, realistic",
  "promptStrength": 0.8,
  "numberOfInferenceSteps": 50
}
  • image (required): URI of the initial image for generating variations.
  • prompt (optional): Describes desired characteristics (default: "a bedroom").
  • guidanceScale (optional): Adjusts the strength of classifier-free guidance (default: 15, range: 1 to 50).
  • negativePrompt (optional): Discourages certain elements in the design.
  • promptStrength (optional): Influences the prompt's effect on the output (default: 0.8, range: 0 to 1).
  • numberOfOutputs (optional): How many images to generate (default: 1, range: 1 to 4).
  • numberOfInferenceSteps (optional): Total denoising steps influencing quality (default: 50, range: 1 to 500).

Output

The action returns an array of URIs pointing to the generated image variations. Here’s an example of the output:

[
  "https://assets.cognitiveactions.com/invocations/07f761ff-771f-4589-a083-2f5791c620c1/f79b695c-2e59-4ce8-af32-0330274a3d32.png",
  "https://assets.cognitiveactions.com/invocations/07f761ff-771f-4589-a083-2f5791c620c1/7e8d240d-0feb-4cf5-af8f-bad7de4b40f2.png",
  "https://assets.cognitiveactions.com/invocations/07f761ff-771f-4589-a083-2f5791c620c1/91ec549c-19ff-4958-8c01-4860e5aa47d6.png",
  "https://assets.cognitiveactions.com/invocations/07f761ff-771f-4589-a083-2f5791c620c1/fad95656-885e-4125-9e01-62554e9d1fde.png"
]

Conceptual Usage Example (Python)

Here’s how you can invoke the Generate Image Variations 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 = "4ab56a94-ae67-4176-bde4-87e1d7f642f9"  # Action ID for Generate Image Variations

# Construct the input payload based on the action's requirements
payload = {
    "image": "https://replicate.delivery/pbxt/LsHQZEKjufoB7rxwbmLYrr9Cn4IdzWIDBuxI8rtyHDKQNVAq/bedroom.jpg",
    "prompt": "a bedroom",
    "guidanceScale": 15,
    "negativePrompt": "lowres, watermark, banner, logo, watermark, contactinfo, text, deformed, blurry, blur, out of focus, out of frame, surreal, extra, ugly, upholstered walls, fabric walls, plush walls, mirror, mirrored, functional, realistic",
    "promptStrength": 0.8,
    "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, you replace the API key and specify the action ID for generating image variations. The input payload is structured according to the action's requirements, and the response is handled to display the results or any errors encountered.

Conclusion

The Generate Image Variations action from the crdbello/1st API provides developers with a robust tool for creating unique visual content effortlessly. By leveraging customizable parameters, you can enhance your applications with dynamic images tailored to specific needs. Start integrating these Cognitive Actions today and explore the endless creative possibilities they offer!