Blog

Luis Majano

March 18, 2025

Spread the word


Share your thoughts

Welcome to the Future of AI in BoxLang

We are thrilled to introduce BoxLang Gen AI, a powerful and intuitive module that brings seamless AI generation capabilities to your BoxLang applications. With a fluent, functional API, this module allows developers to interact with multiple AI providers in a consistent and abstracted manner.

If you're looking for even more power, check out our bx-aiplus module (Coming Soon), available as part of our BoxLang +/++ subscriptions, which extends this module with additional AI providers, enhanced capabilities, and advanced features.

Open Source & Easy to Get Started

BoxLang AI is open-source, licensed under the Apache 2.0 license, and easy to install:

install-bx-module bx-ai

For CommandBox-based web applications, add it to your server.json or use:

box install bx-ai

Once installed, you can start leveraging built-in functions (BIFs) for AI interactions.

Quick Example

// chat.bxs
answer = aiChat( "How amazing is BoxLang?" )
println( answer )

Review Ortus Books

Supported AI Providers

BoxLang AI supports multiple Large Language Model (LLM) providers:

  • OpenAI
  • DeepSeek
  • Gemini
  • Grok
  • Perplexity

More providers are available in the bx-aiplus module.

Key Features

  • Multi-provider integration
  • Fluent API for composing AI interactions
  • Asynchronous chat requests
  • Global defaults for streamlined requests
  • Raw chat request composition
  • Support for AI service and tool creation
  • System message support

Configuration

You can configure the module by adding settings to boxlang.json:

{
    "modules": {
        "bxai": {
            "provider": "openai",
            "apiKey": "your-api-key",
            "defaultParams": {
                "model": "gpt-3.5-turbo",
                "temperature": 0.5
            }
        }
    }
}

Global Functions (BIFs)

BoxLang AI exposes several global functions (BIFs) for AI interactions:

aiChat() - Simple AI Chat

aiChat( "Write a haiku about recursion in programming." )

aiChatAsync() - Asynchronous Chat

For non-blocking AI interactions, use:

var future = aiChatAsync( "Write a haiku about recursion." )
    .then( result -> println( "AI Response: " + result ) )
    .onError( error -> writeLog( text: "AI Chat failed: " + error.getMessage(), type: "error" ) )
println( future.get() )

aiChatRequest() - Compose a Raw Chat Request

chatRequest = aiChatRequest(
    "Write a haiku about recursion in programming.",
    { model: "gpt-3.5-turbo", temperature: 0.5 },
    { provider: "grok", timeout: 10 }
);
response = aiService().invoke( chatRequest );

aiMessage() - Build AI Messages

aiChat(
    aiMessage()
        .system( "You are a helpful assistant." )
        .user( "Write a haiku about recursion in programming." )
);

aiService() - AI Service Objects

Create an AI Service reference for reusable interactions:

service = aiService( "openai" ).configure( "myApiKey" );
response = service.invoke( aiChatRequest( "Explain quantum computing." ) );

aiTool() - AI Tool Creation

Define tools for real-time system processing:

tool = aiTool( "get_weather", "Fetches real-time temperature.", location -> {
    return (location contains "San Francisco") ? "68F" : "unknown";
});
result = aiChat( "What's the temperature in San Francisco?", { tools: [ tool ] } );
println( result );

Resources

Looking for more information, support, or community engagement? Check out the following resources:

Conclusion

With BoxLang Gen AI, integrating Large Language Models into your applications has never been easier. Whether you're interacting with OpenAI, DeepSeek, Gemini, or other providers, this fluent and functional API empowers you to build powerful AI-driven applications effortlessly.

Get started today with BoxLang AI and take your applications to the next level!

Review Ortus Books

Add Your Comment

Recent Entries

12 Days of BoxLang - Day 4: TestBox

12 Days of BoxLang - Day 4: TestBox

Today we’re celebrating one of the most exciting new additions to the BoxLang ecosystem:

the TestBox BoxLang CLI Runner — a fast, native way to run your TestBox tests directly through the BoxLang Runtime. ⚡

No server required. No CommandBox needed. Just pure, ultra-fast BoxLang-powered testing from the command lineon Windows, Mac, and Linux.

If you’re building modern applications with BoxLang — web apps, CLIs, serverless functions, Android apps, or OS-level utilities — this new feature gives you a unified, flexible testing workflow you can run anywhere.

Victor Campos
Victor Campos
December 13, 2025
12 days of BoxLang - Day 3: SocketBox!

12 days of BoxLang - Day 3: SocketBox!

As BoxLang continues evolving into a modern, high-performance, JVM-based runtime, real-time communication becomes essential for the applications we all want to build: dashboards, collaboration tools, notifications, live feeds, multiplayer features, and more.

That’s where SocketBox steps in — the WebSocket upgrade listener built to work seamlessly with CommandBox and the BoxLang MiniServer. ⚡

Today, for Day 3, we’re highlighting how SocketBox supercharges BoxLang development by giving you fast, flexible, and framework-agnostic WebSocket capabilities.

Maria Jose Herrera
Maria Jose Herrera
December 12, 2025
12 Days of BoxLang - Day 2: CommandBox

12 Days of BoxLang - Day 2: CommandBox

BoxLang + CommandBox: The Enterprise Engine Behind Your Deployments

For Day 2 of our 12 Days of Christmas series, we’re diving into one of the most powerful parts of the BoxLang ecosystem: CommandBox the defacto enterprise servlet deployment platform for BoxLang.

If BoxLang is the language powering your applications, CommandBox is the engine room behind it all. ⚙️

Victor Campos
Victor Campos
December 11, 2025