Create Stunning Images with the davisbrown/photo-glow Cognitive Actions

23 Apr 2025
Create Stunning Images with the davisbrown/photo-glow Cognitive Actions

In today's digital landscape, generating high-quality images with unique effects can greatly enhance user experience and engagement. The davisbrown/photo-glow API provides developers with powerful Cognitive Actions that allow for the creation of stunning photographic images with a beautiful glow effect. By utilizing advanced techniques like Flux LoRA, this API empowers developers to produce visually striking outputs that can be easily integrated into applications.

Prerequisites

Before you begin using the Cognitive Actions, ensure you have the following:

  • An API key for the Cognitive Actions platform, which is essential for making authenticated requests.
  • Basic understanding of JSON format and HTTP requests.

In a typical integration, authentication can be achieved by passing the API key in the headers of your requests.

Cognitive Actions Overview

Generate Photo Glow Image

Description: This action allows you to generate photographic images with a beautiful glow effect, utilizing Flux LoRA to impart a light neon glow to the background scenery. It uses a specified model to achieve high-quality, glowing photographic outputs.

Category: Image Generation

Input

The input for this action requires a structured JSON payload. Below are the required and optional fields based on the schema:

  • Required:
    • prompt: A descriptive text prompt for generating the image.
  • Optional:
    • model: Specifies the model to use for inference (default is dev).
    • mask: An image mask for inpainting mode.
    • seed: A random seed for reproducibility.
    • image: An input image for image-to-image or inpainting mode.
    • width, height: Dimensions for custom aspect ratios.
    • loraScale, additionalLoraScale: Defines intensity for LoRA.
    • aspectRatio: Sets the aspect ratio for the image.
    • numberOfOutputs: The number of images to generate (default is 1).
    • imageOutputFormat, imageOutputQuality: Format and quality for the output image.
    • diffusionGuidanceScale, numberOfInferenceSteps: Parameters to adjust the image generation process.

Example Input:

{
  "model": "dev",
  "prompt": "Direct view of an individual in a tailored charcoal grey blazer and trousers, in the style of TOK. Dramatic side lighting casts long shadows, emphasizing texture. The infinite sky is a moody mix of storm greys and silvers, with streaks of electric blue lightning in the distance. Subtle amber accents glint on the blazer's buttons.",
  "loraScale": 1,
  "aspectRatio": "4:5",
  "numberOfOutputs": 3,
  "imageOutputFormat": "webp",
  "imageOutputQuality": 80,
  "additionalLoraScale": 0.8,
  "diffusionGuidanceScale": 3.5,
  "numberOfInferenceSteps": 28
}

Output

The output of this action typically consists of URLs pointing to the generated images. The example output might look like this:

Example Output:

[
  "https://assets.cognitiveactions.com/invocations/f96cd6f9-7848-4ab2-b051-1b08e7475de8/9a6d6d7e-5acd-443e-8e06-5507db8f91b6.webp",
  "https://assets.cognitiveactions.com/invocations/f96cd6f9-7848-4ab2-b051-1b08e7475de8/300265e4-cc19-4895-8f1c-e045cff15b9d.webp",
  "https://assets.cognitiveactions.com/invocations/f96cd6f9-7848-4ab2-b051-1b08e7475de8/8bcd1e62-1c9c-4d65-b706-1be19b741753.webp"
]

Conceptual Usage Example (Python)

Here’s a conceptual Python code snippet that demonstrates how to call the Cognitive Actions execution endpoint for generating a photo glow image:

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 = "c47524dd-950e-4b61-b470-2f33a9ef1428" # Action ID for Generate Photo Glow Image

# Construct the input payload based on the action's requirements
payload = {
    "model": "dev",
    "prompt": "Direct view of an individual in a tailored charcoal grey blazer and trousers, in the style of TOK. Dramatic side lighting casts long shadows, emphasizing texture. The infinite sky is a moody mix of storm greys and silvers, with streaks of electric blue lightning in the distance. Subtle amber accents glint on the blazer's buttons.",
    "loraScale": 1,
    "aspectRatio": "4:5",
    "numberOfOutputs": 3,
    "imageOutputFormat": "webp",
    "imageOutputQuality": 80,
    "additionalLoraScale": 0.8,
    "diffusionGuidanceScale": 3.5,
    "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 code snippet, replace YOUR_COGNITIVE_ACTIONS_API_KEY with your actual API key. The payload is structured according to the specified requirements for the "Generate Photo Glow Image" action.

Conclusion

The davisbrown/photo-glow Cognitive Actions provide developers with a straightforward way to integrate stunning image generation capabilities into their applications. By leveraging the power of AI, you can create visually appealing content that enhances user engagement and experience. Explore various configurations and parameters to achieve the desired results and unlock new creative possibilities in your projects!