Create Stunning Custom Images with robsanz/stevebl Cognitive Actions

22 Apr 2025
Create Stunning Custom Images with robsanz/stevebl Cognitive Actions

In the world of digital content creation, the ability to generate custom images tailored to specific needs can significantly enhance user engagement and creativity. The robsanz/stevebl API offers an exciting set of Cognitive Actions designed for image generation, allowing developers to produce customized images using inpainting and image-to-image processing. These actions provide a flexible framework for creating unique visuals, leveraging user-defined parameters such as width, height, and aspect ratio. With various model options and output settings, developers can easily integrate powerful image generation capabilities into their applications.

Prerequisites

To get started with the robsanz/stevebl Cognitive Actions, you’ll need an API key for access to the service. This key should be included in the headers of your requests for authentication. Ensure that you have the necessary development environment set up to make HTTP requests, as you will be working with JSON payloads to invoke the actions.

Cognitive Actions Overview

Generate Custom Image

The Generate Custom Image action allows you to produce personalized images by utilizing inpainting and image-to-image processing techniques. You can specify various parameters, including the model for inference and the output format, to achieve your desired results.

Input

The input schema requires the following fields:

  • prompt (string, required): The text prompt guiding the image generation (e.g., "STEVEBL in a little fish boat").
  • Additional optional fields include:
    • model (string): Selects the inference model (default: "dev").
    • width (integer): Defines the image's width (only if aspect_ratio is set to custom).
    • height (integer): Defines the image's height (only if aspect_ratio is set to custom).
    • aspectRatio (string): Determines the aspect ratio of the generated image (default: "1:1").
    • outputFormat (string): Specifies the output format (default: "webp").

Here is an example of a JSON payload for invoking this action:

{
  "model": "dev",
  "goFast": false,
  "prompt": "STEVEBL in a little fish boat",
  "loraScale": 1,
  "megapixels": "1",
  "aspectRatio": "1:1",
  "outputFormat": "webp",
  "guidanceScale": 3,
  "outputQuality": 80,
  "extraLoraScale": 1,
  "promptStrength": 0.8,
  "numberOfOutputs": 1,
  "numberOfInferenceSteps": 28
}

Output

The action typically returns a URL pointing to the generated image. Here’s an example of a possible output:

[
  "https://assets.cognitiveactions.com/invocations/aadacb25-43b1-4c82-a70c-34ae7b7a66aa/c6b0a6dc-9811-41bc-8c16-6e42e6801eb0.webp"
]

This URL links directly to the generated image file, allowing for immediate use in applications.

Conceptual Usage Example (Python)

Here’s a conceptual example of how a developer might call the Generate Custom Image 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 = "765a928f-5054-46c9-b4c0-4fef7b63c776"  # Action ID for Generate Custom Image

# Construct the input payload based on the action's requirements
payload = {
    "model": "dev",
    "goFast": False,
    "prompt": "STEVEBL in a little fish boat",
    "loraScale": 1,
    "megapixels": "1",
    "aspectRatio": "1:1",
    "outputFormat": "webp",
    "guidanceScale": 3,
    "outputQuality": 80,
    "extraLoraScale": 1,
    "promptStrength": 0.8,
    "numberOfOutputs": 1,
    "numberOfInferenceSteps": 28
}

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, the payload is structured according to the action's input requirements. The action_id references the specific action for generating custom images, and the API key ensures proper authentication.

Conclusion

The robsanz/stevebl Cognitive Actions provide developers with powerful tools to generate stunning custom images tailored to specific prompts and requirements. By leveraging these actions, you can enhance the visual appeal of your applications and engage users in innovative ways. Consider experimenting with different parameters and settings to explore the full potential of image generation in your projects!