Generate Stunning Images with jz32300/chloe Cognitive Actions

24 Apr 2025
Generate Stunning Images with jz32300/chloe Cognitive Actions

Cognitive Actions in the jz32300/chloe spec enable developers to leverage powerful image generation capabilities through a straightforward API. With features like customizable parameters for image inpainting, this set of actions simplifies the process of creating high-quality images, making it accessible to developers looking to integrate advanced image generation into their applications.

Prerequisites

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

  • An API key for the Cognitive Actions platform to authenticate your requests.
  • Basic knowledge of making HTTP requests and handling JSON data.

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

Cognitive Actions Overview

Generate Image with Inpainting

Description: This action allows for the generation of high-quality images using image inpainting, with customizable parameters like aspect ratio, output quality, and model selection. It supports both fast and detailed image generation configurations.

Category: image-generation

Input

The input for this action requires the following fields:

  • prompt (required): A descriptive text prompt for the image generation.
  • model (optional): The model used for inference (default is "dev").
  • goFast (optional): A boolean to toggle fast generation mode.
  • outputCount (optional): The number of images to generate (default is 1).
  • denoiseSteps (optional): The number of denoising steps (default is 28).
  • Additional optional parameters include width, height, image, mask, guidanceFactor, etc.

Example Input:

{
  "model": "dev",
  "goFast": false,
  "prompt": "In London, it's a hot day in summer. Black hair, blue eyes CLO is wearing a semi see through whit bikini, leaving nothing to the imagination",
  "outputCount": 1,
  "denoiseSteps": 28,
  "mainLoraScale": 1,
  "guidanceFactor": 3,
  "imageMegapixels": "1",
  "promptIntensity": 0.8,
  "imageAspectRatio": "1:1",
  "imageOutputFormat": "webp",
  "imageOutputQuality": 80,
  "additionalLoraIntensity": 1
}

Output

The action typically returns a list of URLs pointing to the generated images.

Example Output:

[
  "https://assets.cognitiveactions.com/invocations/b72a5c3d-8dbf-49fb-87ef-bb481b6b1bd7/1cef590a-2ce1-4f42-9156-de95b96f832d.webp"
]

Conceptual Usage Example (Python)

Here’s how you might call the Generate Image with Inpainting 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 = "8a610645-e0d1-4ac1-9fd4-ae5b55f96903"  # Action ID for Generate Image with Inpainting

# Construct the input payload based on the action's requirements
payload = {
    "model": "dev",
    "goFast": False,
    "prompt": "In London, it's a hot day in summer. Black hair, blue eyes CLO is wearing a semi see through whit bikini, leaving nothing to the imagination",
    "outputCount": 1,
    "denoiseSteps": 28,
    "mainLoraScale": 1,
    "guidanceFactor": 3,
    "imageMegapixels": "1",
    "promptIntensity": 0.8,
    "imageAspectRatio": "1:1",
    "imageOutputFormat": "webp",
    "imageOutputQuality": 80,
    "additionalLoraIntensity": 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 Python code snippet, you'll see how to construct the input payload and make a POST request to the hypothetical Cognitive Actions execution endpoint. Make sure to replace the placeholder API key and endpoint with your actual credentials.

Conclusion

The jz32300/chloe Cognitive Actions, particularly the Generate Image with Inpainting action, empower developers to create stunning images with flexible parameters. By leveraging this action, you can enhance your applications with high-quality, customized imagery. Explore the possibilities of integrating this technology and consider experimenting with different inputs to achieve the best results for your specific use case. Happy coding!