Create Stunning Images with levelsio/disposable-camera Cognitive Actions

22 Apr 2025
Create Stunning Images with levelsio/disposable-camera Cognitive Actions

In today's digital landscape, image generation has become a game-changer for developers looking to enhance their applications with unique visuals. The levelsio/disposable-camera Cognitive Actions provide a powerful API for generating images that replicate the nostalgic look of disposable camera photos. Utilizing sophisticated models optimized for various inference steps, these actions enable developers to create high-quality imagery effortlessly.

Prerequisites

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

  • An API key for the Cognitive Actions platform.
  • Basic knowledge of making HTTP requests in your programming language of choice.

Authentication typically involves passing your API key in the headers of your requests to access the Cognitive Actions services.

Cognitive Actions Overview

Create Disposable Camera Photos

The Create Disposable Camera Photos action allows you to generate images that mimic the aesthetic of photos taken with a disposable camera. This action is categorized under image-generation and is perfect for developers looking to add a vintage touch to their applications.

Input

The input schema defines several parameters, but the most critical is the prompt, which specifies the desired image characteristics. Below is an overview of the required and optional fields.

  • Required:
    • prompt (string): A text prompt for image generation. Example: "photo in the style of STL".
  • Optional:
    • model (string): Choose between "dev" and "schnell". Default is "dev".
    • image (string): URI of the input image for image-to-image or inpainting mode.
    • aspectRatio (string): Sets the aspect ratio for the generated image. Default is "1:1".
    • width (integer): Width of the image in pixels (valid if aspectRatio is "custom").
    • height (integer): Height of the image in pixels (valid if aspectRatio is "custom").
    • fileFormat (string): Specifies the output image format (webp, jpg, or png). Default is webp.
    • outputQuantity (integer): Number of images to generate (1-4). Default is 1.

Example Input:

{
  "model": "dev",
  "prompt": "photo in the style of STL",
  "fileFormat": "webp",
  "aspectRatio": "16:9",
  "imageQuality": 80,
  "guidanceScale": 3.5,
  "denoisingSteps": 28,
  "extraLoraScale": 0.8,
  "outputQuantity": 4,
  "promptStrength": 0.8,
  "modelWeightScale": 1
}

Output

The action returns a list of URLs pointing to the generated images. Here’s what the output might look like:

Example Output:

[
  "https://assets.cognitiveactions.com/invocations/3a1ee533-fbd2-45b7-a032-72ab8de7e88b/65fb20b9-a4e1-4a7a-87c7-e4f3ce940051.webp",
  "https://assets.cognitiveactions.com/invocations/3a1ee533-fbd2-45b7-a032-72ab8de7e88b/b270d446-9fee-4497-be59-abe51f4357b7.webp",
  "https://assets.cognitiveactions.com/invocations/3a1ee533-fbd2-45b7-a032-72ab8de7e88b/5d95b462-c838-4966-bf98-3ca24d7f8082.webp",
  "https://assets.cognitiveactions.com/invocations/3a1ee533-fbd2-45b7-a032-72ab8de7e88b/cc1db54f-582d-4046-859a-fa807f5e2db1.webp"
]

Conceptual Usage Example (Python)

Here’s how you might call the Create Disposable Camera Photos action using Python. This example demonstrates how to structure your input payload and make the request:

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 = "a34f239d-1d50-46de-b841-5f89d25f70d9"  # Action ID for Create Disposable Camera Photos

# Construct the input payload based on the action's requirements
payload = {
    "model": "dev",
    "prompt": "photo in the style of STL",
    "fileFormat": "webp",
    "aspectRatio": "16:9",
    "imageQuality": 80,
    "guidanceScale": 3.5,
    "denoisingSteps": 28,
    "extraLoraScale": 0.8,
    "outputQuantity": 4,
    "promptStrength": 0.8,
    "modelWeightScale": 1
}

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 is set to the ID of the Create Disposable Camera Photos action. The input payload is structured to meet the action's requirements.

Conclusion

The levelsio/disposable-camera Cognitive Actions empower developers to create stunning images that evoke the charm of disposable cameras, all while providing a flexible set of parameters for customization. By integrating these actions into your applications, you can enhance user experience and offer unique visual content effortlessly.

Start experimenting with these actions today, and transform how users interact with visuals in your projects!