Create Stunning Images with Constructivist Style Using AI

26 Apr 2025
Create Stunning Images with Constructivist Style Using AI

The "Constructiviststyle" service offers developers the ability to generate visually striking images inspired by constructivist art principles. This powerful API leverages Cognitive Actions to transform text prompts into unique artwork while allowing for extensive customization. With features such as image inpainting, adjustable image dimensions, output quality, and various style options, developers can create tailored images for a multitude of applications.

Imagine being able to generate artwork for marketing campaigns, educational materials, or social media posts, all while maintaining a cohesive aesthetic. The flexibility of this service means that whether you're aiming for a minimalist design or an intricate composition, you can achieve it quickly and efficiently.

Prerequisites

Before you start utilizing the Constructiviststyle Cognitive Actions, you'll need an API key to access the service. Additionally, familiarity with making API calls will be beneficial for seamless integration into your projects.

Generate Image with Constructivist Style

This action allows you to create images based on a specified style and color palette, driven by a customizable text prompt. It solves the challenge of generating unique artistic images that align with specific themes or narratives.

Input Requirements: To use this action, you must provide a prompt that describes the desired image. Additional optional parameters include:

  • mask: Provides an image mask for inpainting.
  • seed: A random seed for reproducibility.
  • image: An input image for modifications.
  • model: Choose between the 'dev' model for detailed images or the 'schnell' model for faster results.
  • width and height: Specify dimensions if the aspect ratio is set to custom.
  • guidanceScale: Adjusts how closely the output adheres to the prompt.
  • outputQuality: Determines the quality of the generated image.

Expected Output: The output will be a URL link to the generated image in the specified format (e.g., webp, jpg, png).

Use Cases for this Specific Action:

  • Creative Marketing: Generate eye-catching visuals for campaigns that resonate with specific target audiences.
  • Social Media Content: Create unique posts that stand out in crowded feeds, enhancing brand visibility.
  • Educational Resources: Develop illustrative materials that convey complex concepts through artistic representation.
  • Personal Projects: Craft personalized artwork for gifts or personal use, tailored to individual tastes and themes.
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 = "6da55683-c503-4049-8f99-2dd2fa979c2f" # Action ID for: Generate Image with Constructivist Style

# Construct the exact input payload based on the action's requirements
# This example uses the predefined example_input for this action:
payload = {
  "model": "dev",
  "prompt": "Generate image using Pou style and the colour palette it has. Make the main figures Cats, have them in a nicely forested patch of land that is getting destroyed and burned by capitalistic greed. Make sure the image is minimalist and not a lot of detail.",
  "loraScale": 1,
  "numOutputs": 1,
  "guidanceScale": 3.5,
  "outputQuality": 90,
  "extraLoraScale": 1,
  "promptStrength": 0.8,
  "imageAspectRatio": "1:1",
  "imageOutputFormat": "webp",
  "numInferenceSteps": 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 Constructiviststyle Cognitive Actions empower developers to easily create and customize images that reflect unique artistic styles. By leveraging customizable prompts and various output options, you can generate artwork that meets specific needs across different platforms and industries.

To get started, integrate the API into your application, experiment with different prompts and parameters, and unleash your creativity. Whether for commercial or personal use, the possibilities are endless!