Generate Stunning Images from Text with the mcai/deliberate-v2 Cognitive Actions

22 Apr 2025
Generate Stunning Images from Text with the mcai/deliberate-v2 Cognitive Actions

In the realm of artificial intelligence, image generation from textual descriptions has emerged as a groundbreaking capability. The mcai/deliberate-v2 API provides a powerful Cognitive Action that allows developers to create visually stunning images based on detailed prompts. By utilizing the Deliberate v2 model, you can not only generate images but also fine-tune various parameters to enhance the output, ensuring that it meets your specific needs. This article will walk you through how to effectively integrate this action into your applications.

Prerequisites

To get started with the mcai/deliberate-v2 Cognitive Actions, you will need:

  • An API key from the Cognitive Actions platform to authenticate your requests.
  • Basic knowledge of making HTTP requests and handling JSON data.

Authentication is generally handled by including your API key in the request headers, ensuring secure access to the API features.

Cognitive Actions Overview

Generate Image from Text with Deliberate v2

This action enables you to create a new image based on a textual input using the Deliberate v2 model. It offers options for adjusting image dimensions, influencing output through guidance scales, and specifying elements to exclude (negative prompts), allowing for the generation of detailed and visually appealing images.

Input

The input for this action is structured as follows:

{
  "seed": "integer (optional)",
  "width": "integer (default: 512)",
  "height": "integer (default: 768)",
  "prompt": "string (required)",
  "scheduler": "string (default: 'EulerAncestralDiscrete')",
  "guidanceScale": "number (default: 7.5)",
  "negativePrompt": "string (default: 'disfigured, kitsch, ugly...')",
  "numberOfOutputs": "integer (default: 1)",
  "numberOfInferenceSteps": "integer (default: 30)"
}

Here's an example input JSON payload that illustrates the required structure:

{
  "width": 512,
  "height": 768,
  "prompt": "Digital photo of car on the empty parking slot, (((blue and white))) 1956 Renault Dauphine , heavy rain, on aesthetic light glow in the cloudy sky, neon sign in the dark night, winter night, falling snow, foggy night , strong rim lighting, soft contrasted, thunder lightning in the stormy sky, 8k uhd, dlsr, Oled, dark lighting, high quality, film grain, Fujifilm XT3, highly detailed, excellent composition, cinematic concept art, dramatic lighting, trending on artstation by Kaiwan Shaban, James O'Brien, Vadim Ignatiev,",
  "scheduler": "EulerAncestralDiscrete",
  "guidanceScale": 7.5,
  "negativePrompt": "disfigured, kitsch, ugly, oversaturated, greain, low-res, Deformed, blurry, bad anatomy, disfigured, poorly drawn face, mutation, mutated, extra limb, ugly, poorly drawn hands, missing limb, blurry, floating limbs, disconnected limbs, malformed hands, blur, out of focus, long neck, long body, ugly, disgusting, poorly drawn, childish, mutilated, mangled, old, surreal, calligraphy, sign, writing, watermark, text, body out of frame, extra legs, extra arms, extra feet, out of frame, poorly drawn feet, cross-eye, blurry, bad anatomy",
  "numberOfOutputs": 1,
  "numberOfInferenceSteps": 30
}

Output

Upon executing the action, the output will typically return a URL to the generated image. Here’s an example of what the output might look like:

[
  "https://assets.cognitiveactions.com/invocations/2adde78e-48bc-4601-8640-52e597e23acc/b1309eb0-dcab-47fd-861a-442f5daed5de.png"
]

Conceptual Usage Example (Python)

Below is a conceptual Python code snippet that demonstrates how to call the Generate Image from Text action using the Cognitive Actions API:

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 = "ab0cdd61-fc46-4938-9e11-1dd470b2b6b0" # Action ID for Generate Image from Text with Deliberate v2

# Construct the input payload based on the action's requirements
payload = {
    "width": 512,
    "height": 768,
    "prompt": "Digital photo of car on the empty parking slot, (((blue and white))) 1956 Renault Dauphine , heavy rain, ...",
    "scheduler": "EulerAncestralDiscrete",
    "guidanceScale": 7.5,
    "negativePrompt": "disfigured, kitsch, ugly...",
    "numberOfOutputs": 1,
    "numberOfInferenceSteps": 30
}

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 variable is structured according to the input requirements, ensuring that you provide all necessary parameters for generating the image.

Conclusion

The mcai/deliberate-v2 Cognitive Action for generating images from text is a powerful tool that opens up a world of possibilities for developers. By integrating this action into your applications, you can create unique and visually appealing content tailored to your specifications. Explore different prompts, adjust parameters, and unleash your creativity with this remarkable technology. Whether for art, design, or other applications, the potential use cases are endless!