installation
Quick installation guide for BoxLang AI module.
π¦ Installation
Get the BoxLang AI module installed and ready to use in minutes.
βοΈ System Requirements
BoxLang Runtime: 1.8+
Internet: Required for cloud providers (OpenAI, Claude, etc.)
Optional: Docker for running Ollama locally
π Installation Methods
π₯ BoxLang Module Installer
The simplest way to install the module is via the BoxLang Module Installer globally:
install-bx-module bx-aiThis command downloads and installs the module globally, making it available to all BoxLang applications on your system. If you want to install it locally in your cli or other runtimes:
install-bx-module bx-ai --localπ¦ CommandBox Package Manager
For CommandBox-based web applications and runtimes
box install bx-aiThis adds the module to your application's dependencies and installs it in the appropriate location.
π Application Dependencies
Add to your box.json for managed dependencies:
Then run:
π§ Module Configuration
Set up your first AI provider in boxlang.json:
Basic Setup (OpenAI)
Using Environment Variables (Recommended)
Then set the environment variable:
Local AI (Ollama)
For free, local AI with no API costs:
Predefined Providers (v2.1.0+)
Configure multiple providers with default parameters and service options:
Benefits of predefined providers:
β Centralized configuration - All provider settings in one place
β Default parameters - Set model, temperature, and other params per provider
β Service options - Configure custom endpoints, timeouts, headers, and API keys
β Environment-specific - Easy to override for dev/staging/production
β Simplified code - Just reference provider name:
aiModel("ollama")
When you use aiModel("ollama"), it automatically applies the predefined params and options for that provider.
π For detailed provider setup, see Provider Setup Guide
π³ Running Ollama with Docker
For production deployments or easier setup, use the included Docker Compose configuration:
π Quick Start
This starts:
Ollama Server on
http://localhost:11434Web UI on
http://localhost:3000
π― What's Included
The Docker setup provides:
β Ollama LLM Server - Fully configured and ready to use
β Web UI - Browser-based interface for testing and management
β Pre-loaded Models - Automatically pulls
qwen3:0.6b,gemma3, andnomic-embed-textβ Health Checks - Automatic monitoring and restart capabilities
β Persistent Storage - Data stored locally in
./.ollamadirectoryβ Production Ready - Configured with proper restart policies
π Managing the Service
π Accessing the Web UI
Open your browser to http://localhost:3000 and login with:
Email:
admin@boxlang.io(default)Password:
rocks(default)
β οΈ Change these credentials before production use!
π Persistent Storage
All Ollama and Web UI data (models, chat history, configurations) is stored in ./.ollama:
Important: Add .ollama/ to your .gitignore to avoid committing large model files.
βοΈ Before Deploying to Production
Update these settings in docker-compose-ollama.yml:
Change Default Credentials β set strong
WEBUI_ADMIN_USER/WEBUI_ADMIN_PASS(orWEBUI_EMAIL/WEBUI_PASSWORD) values, ideally via Docker secrets or an env file rather than committed to the compose file.Choose Production Models β update the
ollama pulllines in thecommand:block to the models you actually need.Add Resource Limits (recommended):
SSL/TLS - Use a reverse proxy (nginx/traefik) for HTTPS.
See the comments in docker-compose-ollama.yml for complete production setup notes.
βοΈ Configuration Options
π Settings Reference
provider
string
"openai"
Default provider used when none is passed per-call
apiKey
string
""
Default API key for provider
defaultParams
struct
{}
Default request params merged into every call (e.g. model, temperature)
timeout
numeric
90
Default AI request timeout, in seconds
returnFormat
string
"single"
Default return format: single, all, json, xml or raw
logRequest / logResponse
boolean
false
Log AI requests/responses to ai.log
logRequestToConsole / logResponseToConsole
boolean
false
Log AI requests/responses to the console
This is the quick-reference subset. See the Provider Setup Guide for the full settings reference, including memory, audio, image, security, hitl, and gateways.
ποΈ Default Parameters
defaultParams accepts any parameter the target provider's chat API accepts β commonly model, temperature, max_tokens, top_p, and frequency_penalty:
β Verification
Test your installation:
Run it:
If configured correctly, you should see a response from your AI provider.
π§ Troubleshooting
β "No API key provided"
Set the API key for your configured provider, either in boxlang.json or by passing it per-call:
β±οΈ "Connection timeout"
Increase settings.timeout (default 90 seconds) or the per-request options.timeout if you're on a slow network or using a large/local model:
π¦ Ollama not responding
Confirm the container is healthy:
docker compose -f docker-compose-ollama.yml psConfirm the model is pulled:
docker exec ollama ollama listConfirm
chatURLpoints at the right host/port (http://localhost:11434by default)
π Next Steps
Now that you're installed and configured:
Provider Setup Guide - Detailed configuration for all supported providers
Quick Start Guide - Your first AI conversation in 5 minutes
Basic Chatting - Learn the fundamentals
π‘ Quick Tips
Use environment variables for API keys (never commit to git)
Start with Ollama for free development/testing
Try multiple providers to find what works best for your use case
Read the provider guide for cost comparisons and model recommendations
Last updated