Unlock Image Generation with the Josh Generator Cognitive Actions

23 Apr 2025
Unlock Image Generation with the Josh Generator Cognitive Actions

In the world of digital creativity, the Josh Generator offers a powerful set of Cognitive Actions designed specifically for image generation. These actions enable developers to create custom images based on text prompts, leveraging advanced techniques such as inpainting and image customization. By integrating these actions into your applications, you can automate content creation, enhance visual storytelling, and improve user engagement, all while saving time and resources.

Prerequisites

Before diving into the capabilities of the Josh Generator Cognitive Actions, ensure you have the following:

  • An API key for the Cognitive Actions platform.
  • Basic understanding of JSON and API requests.
  • Familiarity with a programming language such as Python to test the integration.

Authentication typically involves passing your API key in the request headers.

Cognitive Actions Overview

Generate Image with Inpainting and Customization

The Generate Image with Inpainting and Customization action allows you to create unique images based on a text prompt, with extensive options for customization, including inpainting and image-to-image transformations. This action is categorized under image-generation.

Input

The action requires a prompt and supports various optional fields to tailor the output:

{
  "model": "dev",
  "prompt": "Two side-by-side shots of Josh and his brand:\n\nLeft: Sad Josh with “$300K profit”\n\nRight: Happy Josh with “$4.3M profit”\nAdd a glowing arrow labeled “One Change”. Text:\n“One Shift = $4M?”",
  "loraScale": 1,
  "aspectRatio": "16:9",
  "outputFormat": "jpg",
  "guidanceScale": 3,
  "outputQuality": 80,
  "enableFastMode": false,
  "promptStrength": 0.8,
  "imageMegapixels": "1",
  "numberOfOutputs": 3,
  "additionalLoraScale": 1,
  "numberOfInferenceSteps": 28
}
  • Required Field:
    • prompt: A descriptive text guiding the image creation.
  • Optional Fields:
    • model: Select between 'dev' and 'schnell'.
    • loraScale, aspectRatio, outputFormat, guidanceScale, and more to customize image attributes.

Output

The action returns a list of image URLs based on the specified parameters:

[
  "https://assets.cognitiveactions.com/invocations/ae8328a7-d135-473a-bfd6-bbe628001d8f/a184336a-1bb8-450d-8119-35b98e860a81.jpg",
  "https://assets.cognitiveactions.com/invocations/ae8328a7-d135-473a-bfd6-bbe628001d8f/c336bd26-c3e0-4884-88a3-add9abe243f2.jpg",
  "https://assets.cognitiveactions.com/invocations/ae8328a7-d135-473a-bfd6-bbe628001d8f/65d57b99-5b29-4668-84e4-e46f4bdd5ac9.jpg"
]

This output can vary, depending on the input parameters and model used.

Conceptual Usage Example (Python)

Here’s a conceptual Python code snippet demonstrating how a developer might call the Generate Image with Inpainting and Customization 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 = "a8b33fe1-1cd8-4b7f-aa91-8a5efcd22e54"  # Action ID for Generate Image with Inpainting and Customization

# Construct the input payload based on the action's requirements
payload = {
    "model": "dev",
    "prompt": "Two side-by-side shots of Josh and his brand:\n\nLeft: Sad Josh with “$300K profit”\n\nRight: Happy Josh with “$4.3M profit”\nAdd a glowing arrow labeled “One Change”. Text:\n“One Shift = $4M?”",
    "loraScale": 1,
    "aspectRatio": "16:9",
    "outputFormat": "jpg",
    "guidanceScale": 3,
    "outputQuality": 80,
    "enableFastMode": false,
    "promptStrength": 0.8,
    "imageMegapixels": "1",
    "numberOfOutputs": 3,
    "additionalLoraScale": 1,
    "numberOfInferenceSteps": 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 code, you replace the placeholder for your API key and endpoint with actual values. The payload is constructed according to the action's input schema, and the response is handled appropriately.

Conclusion

The Josh Generator Cognitive Actions provide an excellent opportunity for developers to harness the power of AI-driven image generation. By integrating the Generate Image with Inpainting and Customization action, you can automate the creation of stunning visuals tailored to your specifications. Whether for marketing, storytelling, or personal projects, these capabilities can elevate your application to new heights. Start experimenting with these actions today and unlock creative potential like never before!