Installation Guide
Prerequisites
Before installing Udility, ensure your system meets the following requirements:
- Python: Version 3.6 or higher.
- System Libraries: Since Udility relies on
cairosvgfor image processing, you must have the Cairo graphics library installed on your operating system.
Installing Cairo
- macOS:
brew install cairo - Linux (Ubuntu/Debian):
sudo apt-get install libcairo2 - Windows: Cairo is typically bundled with the
cairosvgPython wheel, but if you encounter errors, you may need to install the GTK+ stack.
Installation
Install the Udility package directly from PyPI using pip:
pip install Udility
Dependencies
The following Python libraries are automatically resolved and installed during the process:
openai(API communication)cairosvg(SVG to PNG conversion)Pillow(Image handling)matplotlib(Image visualization)
Configuration
Udility Diffuser uses OpenRouter to access Meta Llama-3.5 models. You must provide a valid API key to authenticate requests.
1. Obtain an API Key
Go to OpenRouter to generate a free or paid API key.
2. Set Environment Variables
The library looks for an environment variable named OPENROUTER_API_KEY. You can set this in two ways:
Option A: Persistent (Recommended)
Add this to your shell profile (e.g., .bashrc or .zshrc):
export OPENROUTER_API_KEY='your_api_key_here'
Option B: Runtime (Python script)
Set the variable at the beginning of your script before calling any Udility functions:
import os
os.environ['OPENROUTER_API_KEY'] = 'your_api_key_here'
Verifying Installation
To ensure everything is set up correctly, run a quick test script to generate a simple illustration:
from Udility import diffuser
try:
# This will generate an image, save it as 'test.png', and display it.
diffuser.generate_image_from_text("A simple flowchart of a water cycle.")
print("Installation successful!")
except Exception as e:
print(f"Installation check failed: {e}")
If the installation is correct, a window will pop up displaying the generated SVG illustration, and an output.png file will be created in your working directory.