Generate Stunning Images with the henn0124/jonah Cognitive Actions

24 Apr 2025
Generate Stunning Images with the henn0124/jonah Cognitive Actions

In the world of AI-driven creativity, the henn0124/jonah spec offers a powerful API for developers looking to integrate advanced image generation capabilities into their applications. With its Cognitive Actions, you can easily generate detailed, custom images using prompts and masks, all while leveraging pre-built functionalities that save you time and effort. Whether you're creating artwork, designing graphics, or generating images for content, these actions provide the tools you need to bring your ideas to life.

Prerequisites

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

  • An API key for the Cognitive Actions platform to authenticate your requests. Generally, you'll pass this key in the request headers.
  • Familiarity with JSON as the input and output format for the API calls.
  • A basic understanding of Python to implement the provided code examples.

Cognitive Actions Overview

Generate Image with Mask and Seed

The Generate Image with Mask and Seed action allows you to create images by utilizing a mask for inpainting and a seed for reproducibility. You can choose between two models: dev for detailed inference or schnell for faster results.

Input

The input schema requires the following fields:

  • prompt (required): A text prompt guiding the generated image.
  • mask (optional): URI of the image mask for inpainting.
  • seed (optional): An integer value to ensure reproducible image generation.
  • image (optional): URI of the input image for image-to-image or inpainting mode.
  • width (optional): Width of the generated image in pixels, with constraints.
  • height (optional): Height of the generated image in pixels, with constraints.
  • goFast (optional): Enable faster predictions using a speed-optimized model.
  • modelType (optional): Model to use for inference; defaults to dev.
  • outputCount (optional): Number of outputs to generate.
  • guidanceScale (optional): Scale influencing the diffusion process.
  • outputQuality (optional): Image quality for saved outputs.
  • promptStrength (optional): Strength of the prompt in img2img mode.

Here’s an example input JSON payload:

{
  "prompt": "create a image depiction in the style of JNH of Dramatic scene of a violent storm at sea, with sailors desperately trying to control a small wooden ship while Jonah, a prophet in the Hebrew Bible, sleeps below deck",
  "loraScale": 1,
  "modelType": "dev",
  "outputCount": 1,
  "guidanceScale": 3.5,
  "outputQuality": 90,
  "extraLoraScale": 1,
  "promptStrength": 0.8,
  "imageAspectRatio": "1:1",
  "imageOutputFormat": "webp",
  "inferenceStepCount": 28
}

Output

This action typically returns a URL to the generated image. Here’s a sample output:

[
  "https://assets.cognitiveactions.com/invocations/dea7aa36-901d-4d93-bd13-9fcd98e723fe/42a99e9e-2226-4fb3-99e9-69db782b08f9.webp"
]

Conceptual Usage Example (Python)

Below is a conceptual Python code snippet demonstrating how to call the Generate Image with Mask and Seed 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 = "0f1b0306-3ed9-4587-986d-9017c6adc194"  # Action ID for Generate Image with Mask and Seed

# Construct the input payload based on the action's requirements
payload = {
    "prompt": "create a image depiction in the style of JNH of Dramatic scene of a violent storm at sea, with sailors desperately trying to control a small wooden ship while Jonah, a prophet in the Hebrew Bible, sleeps below deck",
    "loraScale": 1,
    "modelType": "dev",
    "outputCount": 1,
    "guidanceScale": 3.5,
    "outputQuality": 90,
    "extraLoraScale": 1,
    "promptStrength": 0.8,
    "imageAspectRatio": "1:1",
    "imageOutputFormat": "webp",
    "inferenceStepCount": 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 example, replace YOUR_COGNITIVE_ACTIONS_API_KEY with your actual API key. The payload structure aligns with the input schema, ensuring that you provide all necessary parameters.

Conclusion

The henn0124/jonah Cognitive Actions offer developers the ability to create stunning images through programmable interfaces, streamlining the creative process. By integrating these actions into your applications, you can leverage AI-generated art to enhance user experiences, automate design tasks, and explore new creative avenues. Start experimenting with the provided action and watch your ideas come to life!