Create Stunning Images with the rihan-a/wassily-chair Cognitive Actions

21 Apr 2025
Create Stunning Images with the rihan-a/wassily-chair Cognitive Actions

In the world of digital content creation, the ability to generate high-quality images is paramount. The rihan-a/wassily-chair Cognitive Actions offer developers a robust API for generating visually stunning images using advanced techniques like inpainting and image-to-image transformation. With customizable parameters and various model options, these pre-built actions can enhance your applications by effortlessly producing unique images tailored to your specifications.

Prerequisites

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

  • An API key for the Cognitive Actions platform, which you will use to authenticate your requests.
  • Familiarity with making HTTP requests, as you will be sending JSON payloads to the API.

Authentication typically involves including your API key in the headers of your requests, enabling you to securely utilize the provided actions.

Cognitive Actions Overview

Generate Image with Inpainting and Transformation

This action allows you to create visually compelling images by utilizing either image-to-image transformation techniques or inpainting. You can select between the 'dev' and 'schnell' models for varied results, while additional customization options enable you to specify dimensions, quality, and more.

Input

The input schema for this action requires the following fields:

  • prompt (required): A descriptive text prompt that guides the image generation process.
  • model (optional): Choose between "dev" (detailed results) or "schnell" (faster results).
  • megapixels (optional): Specify the approximate number of megapixels for the output image.
  • aspectRatio (optional): Choose the desired aspect ratio of the image.
  • outputFormat (optional): Define the file format for the output images (webp, jpg, png).
  • guidanceScale (optional): A value influencing the diffusion process for image creation.
  • mainLoraScale (optional): Adjusts the intensity of the main LoRA application.
  • additionalLoraScale (optional): Controls the intensity of any additional LoRA applications.
  • numberOfOutputs (optional): Specifies how many images to generate (up to 4).
  • accelerateProcess (optional): Enables faster generation using optimized models.

Example Input:

{
  "model": "dev",
  "prompt": "Bright, open living space with floor-to-ceiling windows. Two red Wassily chairs pair with a minimalist coffee table and an iconic Arco floor lamp. The warm wooden accents and geometric wall pattern add depth to the modernist setting",
  "megapixels": "1",
  "aspectRatio": "16:9",
  "outputFormat": "webp",
  "guidanceScale": 3,
  "mainLoraScale": 1,
  "outputQuality": 80,
  "promptStrength": 0.8,
  "numberOfOutputs": 1,
  "accelerateProcess": false,
  "additionalLoraScale": 1,
  "numberOfInferenceSteps": 28
}

Output

The action returns a link to the generated image, typically in the specified output format.

Example Output:

[
  "https://assets.cognitiveactions.com/invocations/b4d65a54-9443-43b9-b151-edfc68531e19/66adefb3-2a15-446b-9a8c-47a721af903f.webp"
]

Conceptual Usage Example (Python)

Here’s how you might call the Cognitive Actions endpoint to generate an 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 = "f16c5a32-d6f6-4b45-a945-a843bb57adba"  # Action ID for Generate Image with Inpainting and Transformation

# Construct the input payload based on the action's requirements
payload = {
    "model": "dev",
    "prompt": "Bright, open living space with floor-to-ceiling windows. Two red Wassily chairs pair with a minimalist coffee table and an iconic Arco floor lamp. The warm wooden accents and geometric wall pattern add depth to the modernist setting",
    "megapixels": "1",
    "aspectRatio": "16:9",
    "outputFormat": "webp",
    "guidanceScale": 3,
    "mainLoraScale": 1,
    "outputQuality": 80,
    "promptStrength": 0.8,
    "numberOfOutputs": 1,
    "accelerateProcess": False,
    "additionalLoraScale": 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 Python snippet, replace the API key and endpoint with your specific details. The payload variable structures the input JSON as required by the action, and the request is sent to the hypothetical execution endpoint.

Conclusion

The rihan-a/wassily-chair Cognitive Actions provide an excellent opportunity for developers to enhance their applications with advanced image generation capabilities. By leveraging these actions, you can easily create unique, high-quality images tailored to your specifications. Consider experimenting with different prompts and parameters to explore the full potential of these cognitive actions in your projects. Happy coding!