Create Stunning Illustrations with fanyiy/flux-notion-illustration Cognitive Actions

23 Apr 2025
Create Stunning Illustrations with fanyiy/flux-notion-illustration Cognitive Actions

In the era of visual content, the ability to generate unique and appealing images programmatically has become invaluable. The fanyiy/flux-notion-illustration specification offers a powerful Cognitive Action that allows developers to create Notion-style illustrations from text prompts and optional image inputs. Whether you're looking to enhance your application with custom graphics or automate the creation of visual content, these pre-built actions can streamline your workflow and elevate your projects.

Prerequisites

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

  • An API key for the Cognitive Actions platform.
  • Basic knowledge of JSON and how to make HTTP requests.

Authentication typically involves passing your API key in the headers of your requests to access the actions securely.

Cognitive Actions Overview

Generate Notion-Style Illustration

The Generate Notion-Style Illustration action is designed to create images in a Notion-style format based on the text prompts you provide. It supports features such as inpainting, customizable aspect ratios, and multiple output formats, with options to optimize for speed or image quality.

Input

The input is structured as a JSON object, with the following required and optional fields:

  • Required Fields:
    • prompt: The text prompt for generating the image. Example: "NOTION a black and white illustration of a man with a skateboard".
  • Optional Fields:
    • mask: URI of the image mask used in image inpainting mode.
    • seed: An integer for setting a random seed to ensure reproducibility.
    • image: URI of the input image for image-to-image or inpainting modes.
    • width: Specifies the width of the generated image (256 to 1440).
    • height: Specifies the height of the generated image (256 to 1440).
    • goFast: Enables a faster model optimized for speed (boolean).
    • numOutputs: Specifies how many images to generate (1 to 4).
    • guidanceScale: Adjusts guidance during the diffusion process (0 to 10).
    • outputQuality: Determines output image quality (0 to 100).
    • imageAspectRatio: Sets desired aspect ratio (e.g., "1:1", "16:9").
    • imageOutputFormat: Specifies output format (e.g., "webp", "jpg").
    • Additional fields like loraScale, numInferenceSteps, and others control various aspects of the image generation process.

Example Input:

{
  "prompt": "NOTION a black and white illustration of a man with a skateboard",
  "loraScale": 1,
  "numOutputs": 1,
  "guidanceScale": 3.5,
  "outputQuality": 80,
  "extraLoraScale": 0.8,
  "inferenceModel": "dev",
  "imageAspectRatio": "1:1",
  "imageOutputFormat": "webp",
  "numInferenceSteps": 28
}

Output

The action typically returns an array of URLs pointing to the generated images. Here's a sample output:

Example Output:

[
  "https://assets.cognitiveactions.com/invocations/9a8f9e92-c704-44a1-88d3-fa25aeeb2fbf/d78113b5-6ea2-43f3-a256-250eecdffc47.webp"
]

Conceptual Usage Example (Python)

Here's how you might structure a request to invoke the Generate Notion-Style Illustration 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 = "52c166da-0342-437b-b38b-ceb53ce97df7"  # Action ID for Generate Notion-Style Illustration

# Construct the input payload based on the action's requirements
payload = {
    "prompt": "NOTION a black and white illustration of a man with a skateboard",
    "loraScale": 1,
    "numOutputs": 1,
    "guidanceScale": 3.5,
    "outputQuality": 80,
    "extraLoraScale": 0.8,
    "inferenceModel": "dev",
    "imageAspectRatio": "1:1",
    "imageOutputFormat": "webp",
    "numInferenceSteps": 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 snippet, replace YOUR_COGNITIVE_ACTIONS_API_KEY with your actual API key. The payload is structured according to the input requirements of the action. The endpoint URL and request structure are illustrative, focusing on integrating the action effectively.

Conclusion

The fanyiy/flux-notion-illustration Cognitive Action offers a robust solution for generating Notion-style illustrations, enhancing your applications with custom visuals effortlessly. By leveraging the capabilities of this action, you can automate image creation, optimize for quality or speed, and customize outputs according to your project's needs. Explore the potential of visual content generation and elevate your applications today!