Create Stunning Images with DreamShaper XL Turbo Cognitive Actions

22 Apr 2025
Create Stunning Images with DreamShaper XL Turbo Cognitive Actions

Integrating advanced image generation capabilities into your applications can elevate user experiences and enhance creative outputs. The DreamShaper XL Turbo API allows developers to harness the power of AI for generating high-quality images, art, and more. Utilizing pre-built Cognitive Actions, developers can seamlessly create diverse visuals that rival offerings from platforms like Midjourney and DALL-E. In this guide, we’ll explore how to use the DreamShaper XL Turbo actions effectively.

Prerequisites

Before diving into the integration, make sure you have the following:

  • An API key for the Cognitive Actions platform to authenticate your requests.
  • Basic knowledge of JSON and Python for structuring input data and executing API calls.

Typically, authentication is handled by passing your API key in the headers of your requests.

Cognitive Actions Overview

Generate Art with DreamShaper

The Generate Art with DreamShaper action allows you to create stunning images based on text prompts. This action is categorized under image generation and aims to provide a rich variety of artistic styles, from photorealistic images to stylized art pieces.

Input

The input for this action requires several parameters that dictate the characteristics of the generated image. Here's the schema for the input:

  • seed (optional, integer): Random seed for reproducibility. Leave blank to use a randomly generated seed.
  • width (integer): Width of the output image in pixels. Default is 1024.
  • height (integer): Height of the output image in pixels. Default is 1024.
  • prompt (string): Text prompt that describes the desired output image. Default example: "An astronaut riding a rainbow unicorn".
  • scheduler (string): The scheduling algorithm used for generation. Default is K_EULER.
  • guidanceScale (number): Scale factor for classifier-free guidance. Range is 1 to 20, default is 2.
  • applyWatermark (boolean): Indicates whether to apply a watermark to generated images. Default is true.
  • negativePrompt (string): Elements to avoid in the output image (e.g., "ugly, deformed").
  • numberOfOutputs (integer): Total number of images to generate. Allowed range is 1 to 4, default is 1.
  • disableSafetyChecker (boolean): Toggle the safety checker for images. Default is false.
  • numberOfInferenceSteps (integer): Number of denoising steps. Range is 1 to 50, default is 6.

Example Input:

{
  "width": 1024,
  "height": 1024,
  "prompt": "In Casey Baugh's evocative style, art of a beautiful young girl cyborg...",
  "scheduler": "K_EULER",
  "guidanceScale": 2,
  "applyWatermark": true,
  "negativePrompt": "ugly, deformed, noisy, blurry...",
  "numberOfOutputs": 1,
  "numberOfInferenceSteps": 7
}

Output

The output of the action typically returns a URL to the generated image. Here’s an example of the response you can expect:

Example Output:

[
  "https://assets.cognitiveactions.com/invocations/e969b9eb-ae29-41c2-8703-79df6f860adc/78afe909-a1b4-4696-8842-d5fcbe2d64ec.png"
]

Conceptual Usage Example (Python)

Here’s how you might call the Generate Art with DreamShaper 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 = "809b7dbf-b34d-47a7-8511-ab2ab9e95568"  # Action ID for Generate Art with DreamShaper

# Construct the input payload based on the action's requirements
payload = {
    "width": 1024,
    "height": 1024,
    "prompt": "In Casey Baugh's evocative style, art of a beautiful young girl cyborg...",
    "scheduler": "K_EULER",
    "guidanceScale": 2,
    "applyWatermark": True,
    "negativePrompt": "ugly, deformed, noisy, blurry...",
    "numberOfOutputs": 1,
    "numberOfInferenceSteps": 7
}

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 the API key and endpoint with your actual values. The action ID and input payload are structured to match the requirements of the Generate Art with DreamShaper action.

Conclusion

The DreamShaper XL Turbo Cognitive Actions provide a powerful way to integrate sophisticated image generation capabilities into your applications. By leveraging the Generate Art with DreamShaper action, developers can create visually stunning content that can captivate users and enhance creative workflows. As a next step, consider exploring various prompts and configurations to fully exploit the potential of this action in your projects. Happy coding!