Generate Stunning Images with jyoung105/stable-diffusion-3.5-medium Cognitive Actions

24 Apr 2025
Generate Stunning Images with jyoung105/stable-diffusion-3.5-medium Cognitive Actions

In the world of machine learning and AI, image generation has become a fascinating frontier. The jyoung105/stable-diffusion-3.5-medium spec empowers developers to create stunning images from text prompts using the Stable Diffusion model. This powerful set of Cognitive Actions allows for customization of various parameters such as image dimensions, guidance scale, and more, making it easier than ever to integrate advanced image generation capabilities into your applications.

Prerequisites

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

  • An API key for accessing the Cognitive Actions platform.
  • Basic understanding of how to make HTTP requests and handle JSON data.

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

Cognitive Actions Overview

Generate Image Using Stable Diffusion

Description:
This action generates images based on text prompts, allowing users to customize dimensions, guidance scale, and other generation parameters.

Category: image-generation

Input

The input schema for the action is structured as follows:

{
  "seed": "integer (optional)",
  "steps": "integer (default: 28)",
  "width": "integer (default: 1024)",
  "height": "integer (default: 1024)",
  "prompt": "string (required)",
  "guidanceScale": "number (default: 4.5)",
  "negativePrompt": "string (optional)",
  "numberOfImages": "integer (default: 1)"
}

Example Input:

{
  "steps": 28,
  "width": 1024,
  "height": 1024,
  "prompt": "A man with hoodie on, illustration",
  "guidanceScale": 4.5,
  "numberOfImages": 1
}
  • prompt: The text description for the image you want to generate.
  • width and height: Specify the image dimensions (1 to 2048 pixels).
  • steps: Controls the number of denoising steps (1 to 50).
  • guidanceScale: Affects the classifier-free guidance (0 to 20).
  • numberOfImages: Number of images to generate (1 to 4).
  • seed: Optional random seed for reproducibility.
  • negativePrompt: Optional description of elements to exclude from the image.

Output

The action typically returns a list of URLs pointing to the generated images.

Example Output:

[
  "https://assets.cognitiveactions.com/invocations/91e99cc7-7b1f-4513-aea3-5ba73e72a397/eb1b2ca7-9a8d-4878-a778-4887f6b9744d.png"
]

The output will include one or more image URLs based on the numberOfImages parameter.

Conceptual Usage Example (Python)

Below is a conceptual example of how a developer might call the Cognitive Actions execution endpoint to generate an image:

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 = "e8c03cb4-3621-4665-bc43-1f457aff3df7"  # Action ID for Generate Image Using Stable Diffusion

# Construct the input payload based on the action's requirements
payload = {
    "steps": 28,
    "width": 1024,
    "height": 1024,
    "prompt": "A man with hoodie on, illustration",
    "guidanceScale": 4.5,
    "numberOfImages": 1
}

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 snippet:

  • Replace the COGNITIVE_ACTIONS_API_KEY and COGNITIVE_ACTIONS_EXECUTE_URL with your actual values.
  • The action ID and payload are structured according to the requirements of the "Generate Image Using Stable Diffusion" action.
  • The output will include generated image URLs if successful.

Conclusion

The jyoung105/stable-diffusion-3.5-medium Cognitive Actions provide a powerful and flexible way to integrate image generation into your applications. By leveraging customizable parameters, developers can create unique and compelling visuals using simple text prompts. Explore these actions further and start enhancing your applications with stunning AI-generated imagery today!