Transform Your Images with Scribble Stories Cognitive Actions

24 Apr 2025
Transform Your Images with Scribble Stories Cognitive Actions

In the realm of creative applications, the nevernotsean/scribble-stories API provides a powerful set of Cognitive Actions designed to generate unique images based on user inputs. By leveraging these pre-built actions, developers can easily integrate sophisticated image generation capabilities into their applications, enabling users to create visually stunning content with minimal effort. This article will guide you through one of the key actions available in this API, focusing on its input requirements, output results, and providing a conceptual usage example in Python.

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 structure and how to make HTTP requests.
  • Familiarity with Python programming for the provided usage example.

For authentication, you will typically pass your API key in the headers of your requests, allowing access to the Cognitive Actions functionalities.

Cognitive Actions Overview

Create Paper-Mini Image with Illustrated Artstyle

This action is designed to generate a paper-mini image utilizing a unique illustrated artstyle based on user-defined prompts. It allows for extensive customization, including options for seed control, color inversion, background removal, and guidance scale adjustments, making it ideal for creative projects.

Input

The input for this action consists of several fields, which can be structured as follows:

{
  "image": "https://replicate.delivery/pbxt/J533knV8qLslwShFS60LSZyGr9b2XWrvjeKfPqFRZh9C5uP1/head-lion-512.png",
  "prompt": "head of a lion",
  "invertColors": true,
  "guidanceScale": 3,
  "negativePrompt": "",
  "additionalPrompt": "white-background, tk-char, prop",
  "removeBackground": true,
  "numInferenceSteps": 20,
  "additionalNegativePrompt": "shadow, texture, (worst quality, low quality:1.4)"
}
  • image: (string) URI of the input image.
  • prompt: (string) Description to guide the image generation.
  • invertColors: (boolean) Flag to invert colors in the output.
  • guidanceScale: (number) Scale for classifier-free guidance ranging from 1 to 20.
  • negativePrompt: (string) Prompts to exclude from the output.
  • additionalPrompt: (string) Further specifications for image enhancement.
  • removeBackground: (boolean) Indicates whether to remove the background.
  • numInferenceSteps: (integer) Number of inference steps for the image generation.
  • additionalNegativePrompt: (string) More elements to exclude from the generation.

Example Input

{
  "image": "https://replicate.delivery/pbxt/J533knV8qLslwShFS60LSZyGr9b2XWrvjeKfPqFRZh9C5uP1/head-lion-512.png",
  "prompt": "head of a lion",
  "invertColors": true,
  "guidanceScale": 3,
  "negativePrompt": "",
  "additionalPrompt": "white-background, tk-char, prop",
  "removeBackground": true,
  "numInferenceSteps": 20,
  "additionalNegativePrompt": "shadow, texture, (worst quality, low quality:1.4)"
}

Output

Upon successful execution, the action typically returns a URL to the generated image. For example:

[
  "https://assets.cognitiveactions.com/invocations/ccf17a42-608d-43a3-8a8c-2c812fdc486c/142fe72f-bf5a-4d8b-a9e6-479cd9634e07.png"
]

This output consists of an array containing the URL of the generated image.

Conceptual Usage Example (Python)

Here’s how you might call this action using a conceptual Python code snippet:

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 = "388c596b-97cb-40a6-b8e4-73cf0377c770" # Action ID for Create Paper-Mini Image with Illustrated Artstyle

# Construct the input payload based on the action's requirements
payload = {
    "image": "https://replicate.delivery/pbxt/J533knV8qLslwShFS60LSZyGr9b2XWrvjeKfPqFRZh9C5uP1/head-lion-512.png",
    "prompt": "head of a lion",
    "invertColors": True,
    "guidanceScale": 3,
    "negativePrompt": "",
    "additionalPrompt": "white-background, tk-char, prop",
    "removeBackground": True,
    "numInferenceSteps": 20,
    "additionalNegativePrompt": "shadow, texture, (worst quality, low quality:1.4)"
}

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 example, replace YOUR_COGNITIVE_ACTIONS_API_KEY with your actual API key. The input payload is constructed based on the action's requirements, and the action ID is specified to indicate which action to execute.

Conclusion

The nevernotsean/scribble-stories Cognitive Actions offer a powerful way to enhance your applications with image generation capabilities. By utilizing the Create Paper-Mini Image with Illustrated Artstyle action, developers can create unique and visually appealing images tailored to user prompts. Consider exploring additional actions within this API to further enhance your creative projects. Happy coding!