Generate Stunning Images with Pumkino: A Developer's Guide to Cognitive Actions

23 Apr 2025
Generate Stunning Images with Pumkino: A Developer's Guide to Cognitive Actions

In today's digital landscape, the ability to generate custom images programmatically opens up exciting possibilities for developers. The sundai-club/pumkino Cognitive Actions provide a powerful toolset for image generation using a fine-tuned model named Pumkino. With these pre-built actions, you can easily create unique and customized images based on specific prompts and settings, optimizing parameters like resolution, aspect ratio, and more.

Prerequisites

To get started with the Pumkino Cognitive Actions, you need a few prerequisites:

  • API Key: You must have an API key for accessing the Cognitive Actions platform.
  • Basic Understanding of JSON: Familiarity with JSON structure will help you construct the input payloads effectively.

Authentication typically involves passing your API key in the request headers, ensuring secure access to the services.

Cognitive Actions Overview

Generate Images with Pumkino Model

The Generate Images with Pumkino Model action leverages a specialized FLUX.1 model to create custom images based on your input prompts. This action falls under the category of image-generation and offers extensive configuration options to fine-tune your image outputs.

Input

The input schema for this action requires several fields, with "prompt" being mandatory. Here’s a breakdown of the input fields:

  • prompt (string, required): The text prompt for image generation.
  • mask (string, optional): URI to an image mask for inpainting.
  • seed (integer, optional): Seed for reproducibility.
  • image (string, optional): URI to an input image for modification.
  • model (string, optional): Select between "dev" for detailed outputs or "schnell" for faster results (default: "dev").
  • width (integer, optional): Width of the generated image (256 to 1440).
  • height (integer, optional): Height of the generated image (256 to 1440).
  • megapixels (string, optional): Approximate number of megapixels (default: "1").
  • aspectRatio (string, optional): Aspect ratio of the generated image (default: "1:1").
  • outputCount (integer, optional): Number of images to generate (1 to 4).
  • outputFormat (string, optional): File format for the images (default: "webp").
  • guidanceScale (number, optional): Controls the realism and detail (default: 3).
  • inferenceSteps (integer, optional): Number of denoising steps (default: 28).
  • promptStrength (number, optional): Strength of the text prompt (default: 0.8).
  • Additional parameters for advanced customization include scales for LoRA weights, output quality, and options for fast mode.

Here’s an example input JSON payload:

{
  "model": "dev",
  "prompt": "PUMKI is now on the couch and watching TV with a remote control in its belly. Warm colors, cartoon style.",
  "megapixels": "1",
  "aspectRatio": "1:1",
  "outputCount": 1,
  "outputFormat": "webp",
  "guidanceScale": 3,
  "mainLoraScale": 1,
  "outputQuality": 80,
  "enableFastMode": false,
  "inferenceSteps": 28,
  "promptStrength": 0.8,
  "additionalLoraScale": 1
}

Output

The output of this action typically returns a list of URLs pointing to the generated images. Here’s an example of what you might receive:

[
  "https://assets.cognitiveactions.com/invocations/27c06f43-a4f0-480f-9fe9-b43ce174d381/b4fbc121-d43a-4d1d-9899-a368f5aad0ca.webp"
]

Conceptual Usage Example (Python)

Here’s a conceptual example of how to use the Generate Images with Pumkino Model action in 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 = "4240ab61-118a-4b2b-b619-ac2968ebde6f"  # Action ID for Generate Images with Pumkino Model

# Construct the input payload based on the action's requirements
payload = {
    "model": "dev",
    "prompt": "PUMKI is now on the couch and watching TV with a remote control in its belly. Warm colors, cartoon style.",
    "megapixels": "1",
    "aspectRatio": "1:1",
    "outputCount": 1,
    "outputFormat": "webp",
    "guidanceScale": 3,
    "mainLoraScale": 1,
    "outputQuality": 80,
    "enableFastMode": False,
    "inferenceSteps": 28,
    "promptStrength": 0.8,
    "additionalLoraScale": 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 snippet, you will need to replace the placeholder for the API key and ensure the action ID corresponds to the Generate Images with Pumkino Model. The input payload is structured based on the required parameters for generating images.

Conclusion

The Pumkino Cognitive Actions offer a robust way for developers to generate stunning images tailored to specific prompts and configurations. With the flexibility to customize various parameters, the possibilities for creative applications are vast. Consider exploring additional use cases, such as integrating this functionality into web applications, art generation tools, or even game design. Embrace the power of image generation with Pumkino and elevate your projects to new heights!