Create Stunning Artwork with lastmover/purr2 Cognitive Actions

24 Apr 2025
Create Stunning Artwork with lastmover/purr2 Cognitive Actions

In this blog post, we will explore the capabilities of the lastmover/purr2 Cognitive Actions, specifically focusing on the action Generate Purr Artwork. This powerful action allows developers to create digital illustrations featuring the PURR model, optimized for various artistic styles through guidance and experimentation. By leveraging these pre-built actions, you can enhance your applications with advanced image generation capabilities without needing to develop complex algorithms from scratch.

Prerequisites

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

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

Authentication typically involves passing your API key in the request headers, allowing you to securely interact with the Cognitive Actions service.

Cognitive Actions Overview

Generate Purr Artwork

Description: This action creates digital illustrations featuring the PURR model, optimized for diverse styles with guidance and experimentation for improved image quality.

Category: Image Generation

Input

The input schema for this action consists of several fields. At a minimum, you will need to provide a prompt to guide the image generation. Below is a breakdown of the required and optional fields:

  • Required:
    • prompt (string): A description that guides the image generation process. Example: "a digital illustration of PURR reading a book in a cozy library"
  • Optional:
    • mask (string): A URI for an image mask used in inpainting mode.
    • seed (integer): A random seed for reproducible generation.
    • image (string): An input image for image-to-image or inpainting mode.
    • model (string): Choose between "dev" (optimized for quality) and "schnell" (faster results).
    • width (integer): Width of the generated image (if aspect_ratio is set to custom).
    • height (integer): Height of the generated image (if aspect_ratio is set to custom).
    • goFast (boolean): Enable faster image generation.
    • imageFormat (string): Format of the output image (webp, jpg, png).
    • outputCount (integer): Number of outputs to generate (default is 1, maximum is 4).
    • imageQuality (integer): Quality level for the output images (0-100).
    • guidanceScale (number): Scale for the diffusion process.
    • inferenceStepCount (integer): Number of denoising steps (default is 28).
    • Additional parameters related to LoRA scaling and weights.

Example Input:

{
  "model": "dev",
  "goFast": false,
  "prompt": "a digital illustration of PURR reading a book in a cozy library",
  "loraScale": 1,
  "imageFormat": "webp",
  "outputCount": 4,
  "imageQuality": 80,
  "guidanceScale": 3,
  "promptStrength": 1,
  "imageResolution": "1",
  "imageAspectRatio": "1:1",
  "inferenceStepCount": 28,
  "additionalLoraScaling": 1
}

Output

The action typically returns an array of URLs pointing to the generated images based on the input prompt. Here’s an example of what you might receive:

Example Output:

[
  "https://assets.cognitiveactions.com/invocations/557fdd7d-0dc7-4bca-a02e-7dbda54a3a6f/d057e87d-23fe-456c-9440-65989a9ccf1d.webp",
  "https://assets.cognitiveactions.com/invocations/557fdd7d-0dc7-4bca-a02e-7dbda54a3a6f/2925b29b-b010-483c-b80a-7c17e4b2f1ad.webp",
  "https://assets.cognitiveactions.com/invocations/557fdd7d-0dc7-4bca-a02e-7dbda54a3a6f/82161b4d-b3b5-4e33-a64f-eebd08dcfbf5.webp",
  "https://assets.cognitiveactions.com/invocations/557fdd7d-0dc7-4bca-a02e-7dbda54a3a6f/b88e47fb-b985-4303-8399-0f9a823f316f.webp"
]

Conceptual Usage Example (Python)

Here’s how you could call the Generate Purr Artwork 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 = "0c3f8cad-83a5-4633-a723-e545629db21b"  # Action ID for Generate Purr Artwork

# Construct the input payload based on the action's requirements
payload = {
    "model": "dev",
    "goFast": False,
    "prompt": "a digital illustration of PURR reading a book in a cozy library",
    "loraScale": 1,
    "imageFormat": "webp",
    "outputCount": 4,
    "imageQuality": 80,
    "guidanceScale": 3,
    "promptStrength": 1,
    "imageResolution": "1",
    "imageAspectRatio": "1:1",
    "inferenceStepCount": 28,
    "additionalLoraScaling": 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 payload contains the structured input for generating artwork. The endpoint URL and request structure are illustrative and should be confirmed with actual API documentation.

Conclusion

The lastmover/purr2 Cognitive Action for generating artwork allows developers to easily create high-quality digital illustrations. By integrating this action into your applications, you can automate image creation, streamline workflows, and enhance user engagement with visually appealing content.

Consider experimenting with different prompts and parameters to achieve the desired artistic effects, and explore potential use cases such as digital art applications, marketing materials, and more. Happy coding!