Blog

12 Days of BoxLang - Day 6: BoxLang AI

Maria Jose Herrera December 16, 2025

Spread the word

Maria Jose Herrera

December 16, 2025

Spread the word


Share your thoughts

Day 6: BoxLang AI: One Fluent API for Every AI Provider 🎄

BoxLang AI gives you a unified, consistent way to work with Large Language Models—across multiple providers—using a single functional and fluent API. Build AI-powered features directly into your BoxLang apps without juggling different SDKs, formats, or request models.

You can also extend capabilities with bx-aiplus, part of our BoxLang + / ++ subscriptions, which adds more providers, advanced features, and enhancements.


License

BoxLang is open source under the Apache 2 License.


Getting Started

Install the module:

install-bx-module bx-ai

For CommandBox-based web apps:

box install bx-ai

Once installed, simply use the AI global functions in your BoxLang code:

answer = aiChat( "How amazing is BoxLang?" )
println( answer )


Supported Providers

You can use any of these AI providers (API key required):

  • Claude (Anthropic)
  • DeepSeek
  • Gemini
  • Grok
  • OpenAI
  • Perplexity

More providers are available through bx-aiplus.


Features

  • Unified API for multiple AI providers
  • Fluent, functional interface
  • Build structured chat requests
  • Compose messages programmatically
  • Async chat with futures
  • Real-time tools for function calling
  • Global defaults
  • Custom AI service objects
  • And more

Real-Time Tooling Support

ProviderTools
ClaudeYes
DeepSeekYes
GeminiComing Soon
GrokYes
OpenAIYes
PerplexityYes

Configuration (boxlang.json)

You can control defaults globally:

{
	"modules" : {
		"bxai" : {
			"settings": {
				"provider" : "openai",
				"apiKey" : "",
				"defaultParams" : {},
				"timeout" : 30,
				"logRequest" : false,
				"logResponse" : false,
				"logRequestToConsole" : false,
				"logResponseToConsole" : false,
				"returnFormat" : "single"
			}
		}
	}
}


Return Formats

Choose how responses should return:

  • single – Returns one string (default)
  • all – Returns all messages as an array
  • raw – Full provider response for debugging or custom processing

Global Functions (BIFs)

aiChat()

Basic chat request

Return: string/array/struct based on format

aiChatAsync()

Async version with futures

aiChatRequest()

Build raw ChatRequest objects for full control

aiMessage()

Build fluent message objects

aiService()

Create or override AI provider service objects

aiTool()

Create function-calling tools for real-time processing


Quick Examples

Simple chat

result = aiChat( "Hello, world!" )

Async chat

aiChatAsync( "Hello!" )
    .then( r -> println(r) )

Fluent message building

msg = aiMessage()
	.system( "Be helpful" )
	.user( "Hello" )

Custom service

service = aiService( "openai", "my-key" )
	.defaults( { temperature: 0.7 } )

Tool example

tool = aiTool( "weather", "Get weather data", location => getWeather(location) )


aiChat() and aiChatAsync()

messages can be:

  • A string
  • A struct { role, content }
  • An array of message structs
  • A ChatMessage object

You can customize:

  • Provider
  • API key
  • Timeout
  • Logging
  • Return format
  • Provider request params (model, temperature, etc.)

Examples

aiChat( "Write a haiku about recursion." )

aiChat([
	{ role: "system", content: "You are helpful." },
	{ role: "user", content: "Write a haiku about recursion." }
])

Async example with error handling:

var future = aiChatAsync( "Write a haiku" )
    .then( r -> println("AI: " & r) )
    .onError( e -> "Error: " & e.getMessage() )

future.get()


aiChatRequest()

Build a ChatRequest for full control and pass it to a service:

chatRequest = aiChatRequest(
	"Write a haiku",
	{ model: "gpt-4" },
	{ provider: "openai", returnFormat: "raw" }
)

response = aiService().invoke( chatRequest )

ChatRequest gives you getters/setters for:

  • Messages
  • Model
  • Provider
  • Params
  • Headers
  • API Key
  • Logging settings
  • Timeout

And methods for:

  • addHeader
  • merge defaults
  • tool handling
  • model and API key fallback

aiMessage()

Fluent message building:

aiMessage()
	.system( "You are helpful." )
	.user( "Write a haiku" )
	.user( "Now tell me the capital of France." )

Supports:

  • Adding messages
  • Replacing system message
  • Getting system/non-system messages

aiService()

Create and reuse provider service objects:

service = aiService( "grok", "myApiKey" )
	.defaults( { model: "gpt-3.5", temperature: 0.5 } )

response = service.invoke( aiChatRequest( "Write a haiku" ) )

Implements:

  • configure
  • invoke
  • defaults
  • get/set chat URL

aiTool()

Create real-time function-calling tools.

Example:

weatherTool = aiTool(
	"get_weather",
	"Get current temperature for a city.",
	location => {
		if ( location contains "Kansas City" ) return "85";
		if ( location contains "San Salvador" ) return "90";
		return "unknown";
	}
).describeLocation( "City and country" )

Use inside a chat:

result = aiChat(
	"Which city is warmer: Kansas City or San Salvador?",
	{ tools: [ weatherTool ] }
)


Events

The module emits events you can intercept:

EventWhen it FiresUse Cases
onAIRequestBefore request is sentLogging, modification, security
onAIResponseAfter receiving responseCaching, processing, auditing
onAIProviderRequestWhen unsupported provider is requestedRegistering custom providers
onAIProviderCreateAfter service object is createdSetup, overrides

Become a Pioneer or Get a Free Compatibility Report!

BoxLang is growing fast features are expanding, the ecosystem is thriving, and performance is turning heads. But the most exciting part? You can be part of shaping it from the very beginning.

The Pioneer Program is your gateway to early access, unmatched support, and unbeatable value. Here’s what you get:

  1. Everything in BoxLang+, and more:
    • Professional support to get you running smoothly
    • A dedicated Slack channel for direct access to our team, solve issues in seconds
    • Priority handling for your feature requests and bug fixes
  2. Migration done with you, not just for you:
    • Our engineers work alongside your team to migrate your apps end-to-end
    • Guaranteed compatibility, we won’t stop until it works perfectly
  3. Big savings, no hidden tricks:
    • At least 40% off your current licensing costs, locked in early, no surprise charges as you grow

Request More Info


Still Not Convinced?

If you’re unsure how BoxLang will work with your applications, or want clarity before making any decisions, we’ve created a simple, low-risk way to evaluate your path forward:

1. Free BoxLang Compatibility Report

What You Get (Free)

A personalized, expert-driven technical audit designed to help you:

  • Determine how compatible your current CFML codebase is with BoxLang
  • Identify modernization needs before migrating
  • Understand the fastest and safest path to BoxLang adoption
  • Receive direct, practical recommendations from the Ortus engineering team

This is a high-touch, hands-on audit — not an automated scan.

Due to demand, we’ve expanded the number of companies we can accept, but availability is still limited.

👉 Register now — it only takes 3 minutes:

https://forms.gle/QSzjmLVsVHQq59mH6


2. 1-Year Free Non-Production License

Test-drive BoxLang Premium features in your own environment, with no pressure.

  • Explore advanced capabilities safely
  • Experiment and validate assumptions
  • Gain confidence before any production commitment

No rush. No lock-in. Just real experience.

Contact Us


Join the BoxLang Community! ⚡️

Stay connected with the latest updates, BoxLang announcements, Into the Box 2026 news, tutorials, tools, and more.

Subscribe to our newsletter for exclusive updates and early access.

Follow Us

Add Your Comment

Recent Entries

Coming Soon:  Version 4 Docker CommandBox Images with Enhanced Performance

Coming Soon: Version 4 Docker CommandBox Images with Enhanced Performance

CommandBox Docker images were the first CFML docker images and have nearly 2 million pulls, since their inception, to date. It's been a source of pride at Ortus that these images have been the most popular and reliable way to run CFML in containers and we are so very pleased to announce the next evolution, which will be the v4 images which run entirely on the BoxLang CLI and represent a significant overhaul of the image architecture.

These images are now available to test by appending -snapshot to your existing version tags and wil be released as stable, once CommandBox v6 emerges from release candidate status and is published as stable.

Jon Clausen
Jon Clausen
October 30, 2026
Free observability with BxMCP: give your AI agents eyes inside a live BoxLang runtime

Free observability with BxMCP: give your AI agents eyes inside a live BoxLang runtime

Ortus Solutions today announces that bx-mcp, the Model Context Protocol (MCP) server for BoxLang, is now free for everyone. Install it, point any MCP capable client at it, and your AI coding assistant, IDE agent or automation pipeline can inspect and operate a live BoxLang runtime: JVM, caches, datasources, slow requests, schedulers, logs and more. No BoxLang+ subscription required.

Luis Majano
Luis Majano
October 29, 2026
Inherited a CFML Application With Few Tests? Here’s Where to Start!

Inherited a CFML Application With Few Tests? Here’s Where to Start!

You need to change an application that has been running for years.

It might be a ColdFusion customer portal, a Lucee application supporting internal operations, or a CFML system your team is preparing to modernize. People depend on it, but some of its behavior lives in old tickets, scattered documentation, and the memory of whoever has supported it longest.

Now a release is approaching. You know more testing would help. The difficult part is deciding where to begin without putting every other priority on hold.

Start with one important workflow and build evidence around what it needs to do.

Explore Ortus Quality Assurance Services

Maria Jose Herrera
Maria Jose Herrera
October 27, 2026