Create Doodle-Style Images with Notion-Style Cognitive Actions

21 Apr 2025
Create Doodle-Style Images with Notion-Style Cognitive Actions

In the world of digital creativity, the ability to generate unique and aesthetically pleasing images is becoming increasingly important. The Notion Style Cognitive Actions API offers developers an innovative way to create doodle-style images that mirror the aesthetic of Notion. This API utilizes inpainting and image transformation algorithms, providing customization options through various prompts, mask inputs, and refinement techniques to deliver up to four unique outputs per request.

Prerequisites

To get started with the Notion Style Cognitive Actions, you will need an API key for the Cognitive Actions platform. This key will be used for authenticating your requests. Conceptually, you will pass this API key in the headers of your HTTP requests when invoking the actions.

Cognitive Actions Overview

Create Notion Style Doodles

The Create Notion Style Doodles action allows you to generate doodle-style images that reflect the Notion aesthetic. You can customize the output through various parameters, including prompts and masks, to achieve specific visual results.

Category: image-generation

Input

The input for this action is structured as a JSON object with the following fields:

  • mask (string, optional): URI for the input mask used in inpaint mode. Black areas will remain unchanged, while white areas will be inpainted.
  • seed (integer, optional): Random seed for reproducibility. If left blank, a random seed will be generated.
  • image (string, optional): URI for the input image used in img2img or inpaint mode.
  • width (integer, default: 1024): Width of the output image in pixels.
  • height (integer, default: 1024): Height of the output image in pixels.
  • prompt (string, default: "An astronaut riding a rainbow unicorn"): Textual prompt to guide the image generation process.
  • refineStyle (string, default: "no_refiner"): Select the refinement style to apply. Options include no_refiner, expert_ensemble_refiner, and base_image_refiner.
  • additiveScale (number, default: 0.6): Scale applied for LoRA during model inference.
  • customWeights (string, optional): Specify custom LoRA weights for the model.
  • guidanceScale (number, default: 7.5): Scale factor for classifier-free guidance during image generation.
  • applyWatermark (boolean, default: true): Indicates whether to apply a watermark to generated images.
  • negativePrompt (string, optional): Textual inputs to suppress undesirable aspects in the generated image.
  • promptStrength (number, default: 0.8): Determines prompt strength when using img2img or inpainting.
  • numberOfOutputs (integer, default: 1): Defines the number of images to be generated (between 1 and 4).
  • refinementSteps (integer, optional): Number of refinement steps when using base_image_refiner style.
  • schedulingMethod (string, default: "K_EULER"): Selects the scheduling method for the denoising process.
  • highNoiseFraction (number, default: 0.8): Specifies the fraction of noise for expert_ensemble_refiner style.
  • inferenceStepsCount (integer, default: 50): Total number of denoising steps for the image generation process.
  • disableSafetyChecker (boolean, default: false): Enable or disable the safety checker for generated images.

Example Input:

{
  "width": 1024,
  "height": 1024,
  "prompt": "a gentleman otter , black and white, doodle, in the style of TOK,",
  "refineStyle": "no_refiner",
  "additiveScale": 0.6,
  "guidanceScale": 7.5,
  "applyWatermark": true,
  "negativePrompt": "((((ugly)))), (((duplicate))), ((morbid)), ((mutilated)), out of frame, extra fingers, mutated hands, ((poorly drawn hands)), ((poorly drawn face)), (((mutation))), (((deformed))), ((ugly)), blurry, ((bad anatomy)), (((bad proportions))), ((extra limbs)), cloned face, (((disfigured))), out of frame, ugly, extra limbs, (bad anatomy), gross proportions, (malformed limbs), ((missing arms)), ((missing legs)), (((extra arms))), (((extra legs))), mutated hands, (fused fingers), (too many fingers), (((long neck)))",
  "promptStrength": 0.8,
  "numberOfOutputs": 4,
  "schedulingMethod": "K_EULER",
  "highNoiseFraction": 0.8,
  "inferenceStepsCount": 50
}

Output

The action typically returns an array of URLs pointing to the generated images. The output may look like this:

Example Output:

[
  "https://assets.cognitiveactions.com/invocations/1d80a3e8-4d59-4172-a3eb-82b3831ffb29/5125fd7b-91a6-4ee0-bc2c-82f62e056b32.png",
  "https://assets.cognitiveactions.com/invocations/1d80a3e8-4d59-4172-a3eb-82b3831ffb29/06baff6a-8f54-48fa-9e92-310d11cddd7e.png",
  "https://assets.cognitiveactions.com/invocations/1d80a3e8-4d59-4172-a3eb-82b3831ffb29/43d61ff2-cc67-46b2-9703-121878d3ceee.png",
  "https://assets.cognitiveactions.com/invocations/1d80a3e8-4d59-4172-a3eb-82b3831ffb29/0052e3dd-033d-4b60-88c3-ae4a3163e94e.png"
]

Conceptual Usage Example (Python)

Here’s a conceptual Python code snippet to demonstrate how you might call the Create Notion Style Doodles action:

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 = "e6d771fd-2d94-44d0-a453-00a2b9a2982d"  # Action ID for Create Notion Style Doodles

# Construct the input payload based on the action's requirements
payload = {
    "width": 1024,
    "height": 1024,
    "prompt": "a gentleman otter , black and white, doodle, in the style of TOK,",
    "refineStyle": "no_refiner",
    "additiveScale": 0.6,
    "guidanceScale": 7.5,
    "applyWatermark": True,
    "negativePrompt": "((((ugly)))), (((duplicate))), ((morbid)), ((mutilated)), ...",
    "promptStrength": 0.8,
    "numberOfOutputs": 4,
    "schedulingMethod": "K_EULER",
    "highNoiseFraction": 0.8,
    "inferenceStepsCount": 50
}

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 schema, and the action ID for "Create Notion Style Doodles" is included in the request.

Conclusion

The Notion Style Cognitive Actions enable developers to generate unique and stylish images tailored to their needs. By leveraging the parameters provided, you can customize outputs, refine styles, and produce high-quality doodle images efficiently. Start integrating these actions into your applications today and explore the creative possibilities they offer!