Create Stunning Images from Text Prompts with Dannyk

26 Apr 2025
Create Stunning Images from Text Prompts with Dannyk

In today's digital landscape, the ability to generate high-quality images from text descriptions opens up a world of creative possibilities. Dannyk offers a powerful Cognitive Action that allows developers to create detailed images based on prompts, with extensive customization options. This service simplifies the image generation process by enabling users to specify various parameters, including aspect ratio, output format, and even inpainting capabilities. By harnessing the power of AI, developers can enhance their applications with dynamic visuals that are tailored to their specific needs.

Common use cases for this action include generating artwork for marketing materials, producing unique images for social media content, or creating personalized graphics for user engagement. Whether you are building a game, designing a website, or developing an app, the ability to create custom images quickly and efficiently can significantly enhance user experiences.

Prerequisites

Before you begin, ensure you have a valid Cognitive Actions API key and a basic understanding of making API calls. This will enable you to seamlessly integrate the image generation capabilities of Dannyk into your projects.

Generate Image from Prompt with Customization

The "Generate Image from Prompt with Customization" action is designed to create visually stunning images based on a user-defined text prompt. This action addresses the need for personalized and contextually relevant visuals, which can be challenging to source or create manually.

Input Requirements

To use this action, you must provide a structured input that includes the following:

  • prompt: A detailed text description of the desired image content.
  • mask (optional): A URI for an image mask if you wish to use inpainting mode.
  • seed (optional): An integer for reproducibility of image generation.
  • image (optional): An input image for img2img or inpainting mode.
  • model: Choose between "dev" or "schnell" for different inference speeds.
  • width and height: Specify dimensions for the generated image, applicable when using a custom aspect ratio.
  • Additional parameters for customization, including LoRA weights, output quality, and more.

Expected Output

The output of this action will be a URL link to the generated image, which can be easily embedded or used within your applications.

Use Cases for this Specific Action

  • Marketing and Advertising: Generate eye-catching visuals for campaigns that resonate with target audiences.
  • Social Media Content: Create unique graphics or illustrations to enhance posts and engage users.
  • Interactive Applications: Allow users to create personalized images based on their input, fostering a more interactive experience.
  • Creative Projects: Artists and designers can quickly prototype ideas and visualize concepts through detailed image generation.
import requests
import json

# Replace with your actual Cognitive Actions API key and endpoint
# Ensure your environment securely handles the API key
COGNITIVE_ACTIONS_API_KEY = "YOUR_COGNITIVE_ACTIONS_API_KEY"
# This endpoint URL is hypothetical and should be documented for users
COGNITIVE_ACTIONS_EXECUTE_URL = "https://api.cognitiveactions.com/actions/execute"

action_id = "49233cff-b042-449c-b694-1f60233d0907" # Action ID for: Generate Image from Prompt with Customization

# Construct the exact input payload based on the action's requirements
# This example uses the predefined example_input for this action:
payload = {
  "model": "dev",
  "width": 1440,
  "height": 1440,
  "prompt": "DANNYK stands at the DJ booth in a lively nightclub, dressed in a black t-shirt and jeans, headphones around his neck. He skillfully adjusts the mixer, his movements syncing with the beat. Neon lights bathe the room, while the crowd dances in rhythm to the music. The LED wall behind him pulses with dynamic patterns, adding to the electrifying atmosphere as DANNYK feeds off the crowd’s energy, a satisfied smile occasionally crossing his face.",
  "loraIntensity": 1,
  "numMegapixels": "1",
  "enableFastMode": false,
  "numberOfOutputs": 1,
  "imageAspectRatio": "1:1",
  "imageOutputFormat": "png",
  "imageOutputQuality": 80,
  "additionalLoraScale": 1,
  "img2imgPromptStrength": 0.8,
  "diffusionGuidanceScale": 3,
  "numberOfInferenceSteps": 28
}

headers = {
    "Authorization": f"Bearer {COGNITIVE_ACTIONS_API_KEY}",
    "Content-Type": "application/json",
    # Add any other required headers for the Cognitive Actions API
}

# Prepare the request body for the hypothetical execution endpoint
request_body = {
    "action_id": action_id,
    "inputs": payload
}

print(f"--- Calling Cognitive Action: {action.name or action_id} ---")
print(f"Endpoint: {COGNITIVE_ACTIONS_EXECUTE_URL}")
print(f"Action ID: {action_id}")
print("Payload being sent:")
print(json.dumps(request_body, indent=2))
print("------------------------------------------------")

try:
    response = requests.post(
        COGNITIVE_ACTIONS_EXECUTE_URL,
        headers=headers,
        json=request_body
    )
    response.raise_for_status() # Raise an exception for bad status codes (4xx or 5xx)

    result = response.json()
    print("Action executed successfully. Result:")
    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 (non-JSON): {e.response.text}")
    print("------------------------------------------------")

Conclusion

The Dannyk Cognitive Action for generating images from text prompts provides developers with an invaluable tool for enhancing visual content creation. With its extensive customization options and ease of integration, this action can be applied to a wide range of projects, from marketing materials to interactive applications. By leveraging this technology, developers can save time, reduce costs, and create stunning visuals that captivate their audiences.

As a next step, explore the various parameters available to fully harness the capabilities of Dannyk, and consider how this action can elevate your current projects or inspire new ideas.