Create Stunning Images from Text Descriptions with Vzug

26 Apr 2025
Create Stunning Images from Text Descriptions with Vzug

In the world of digital content creation, the ability to generate images from text prompts offers a powerful tool for developers and designers alike. Vzug provides a robust API that allows you to create images using detailed text descriptions, with options for inpainting and refinement to tailor the output to your exact needs. This capability not only streamlines the creative process but also enhances productivity, enabling users to quickly generate visuals that align with their vision.

Imagine scenarios where you need to create unique illustrations for marketing materials, generate concept art for projects, or even produce custom graphics for social media. Vzug’s image generation feature empowers developers to automate these tasks, saving time and effort while unlocking new creative possibilities. With customizable dimensions, styles, and enhancements, Vzug transforms the way you approach image creation.

Prerequisites

To get started with Vzug's Cognitive Actions, you will need an API key for authentication and a basic understanding of making API calls.

Generate Image from Prompt

The "Generate Image from Prompt" action allows you to create images based on specified text descriptions. This action solves the problem of needing custom visuals without the requirement for extensive graphic design skills. By providing a clear prompt, you can guide the image generation process to produce results that meet your expectations.

Input Requirements

The input for this action includes various parameters, such as:

  • Prompt: A text description guiding the image generation (e.g., "In the style of TOK, a photo of a modern kitchen, white marble, large island").
  • Width and Height: Dimensions of the output image, with a default of 1024 pixels.
  • Guidance Scale: A value that influences how closely the output adheres to the prompt, with defaults set to 7.5.
  • Number of Outputs: The number of images to generate, defaulting to 1.
  • Refinement Style: Determines the method of refinement applied to the generated image.

Expected Output

The output is a URI link to the generated image, which can be used directly in applications or displayed on websites. For example:

"https://assets.cognitiveactions.com/invocations/aafdf93b-179e-4669-aacd-53a2d97b4475/f824fa6b-d5e8-45d7-a135-46234579ee5e.png"

Use Cases for this Specific Action

  • Marketing and Advertising: Quickly generate visuals that align with campaign themes or seasonal promotions.
  • Content Creation: Produce unique images for blogs, articles, or social media posts, making your content more engaging.
  • Product Design: Create concept images based on design specifications to visualize products before development.
  • Art and Illustration: Use the action to generate artwork based on creative prompts, aiding artists in brainstorming sessions.
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 = "d710c82d-6296-4adf-9e33-e44b2866dc6f" # Action ID for: Generate Image from Prompt

# Construct the exact input payload based on the action's requirements
# This example uses the predefined example_input for this action:
payload = {
  "width": 1024,
  "height": 1024,
  "prompt": "In the style of TOK, a photo of a modern kitchen, white marble, large island",
  "loraScale": 0.6,
  "guidanceScale": 7.5,
  "applyWatermark": true,
  "inferenceSteps": 50,
  "negativePrompt": "",
  "promptStrength": 0.8,
  "numberOfOutputs": 1,
  "refinementStyle": "no_refiner",
  "schedulingMethod": "K_EULER",
  "highNoiseFraction": 0.8
}

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

Vzug's image generation capabilities offer immense value to developers looking to enhance their projects with custom visuals. By leveraging this action, you can automate the creative process, save valuable time, and produce high-quality images tailored to your specifications. Whether for marketing, content creation, or product design, the possibilities are endless. Start integrating Vzug's Cognitive Actions today to unlock a new realm of creative potential!