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

Must-See Into the Box 2025 Sessions for CommandBox Users!

Must-See Into the Box 2025 Sessions for CommandBox Users!

Power Up your CommandBox experience and practices at Into the Box 2025

Want to get hands-on with the new CommandBox features or learn how others are pushing it to the next level? These are theĀ must-see sessionsĀ at ITB 2025 if you're a CommandBox user:

Maria Jose Herrera
Maria Jose Herrera
April 21, 2025
Must-See ITB 2025 Sessions for TestBox Users!

Must-See ITB 2025 Sessions for TestBox Users!

Are you a fan of TestBox or looking to level up your testing game in 2025? Whether you're just getting started with unit testing or you're already building advanced specs for ColdBox and BoxLang apps,Ā Into the Box 2025Ā has an exciting lineup tailored just for you. Into the Box 2025Ā has an exciting lineup tailored just for you. With the recent launch of TestBox 6.3.0 we have amazing new tools, features and tips and tricks to get your testing experience to the next level, review our sessions and test like a pro efficiently and easy!

FromĀ hands-on testing strategiesĀ toĀ BoxLang innovations, here are the sessions you won’t want to miss this May — and why they matter to you as a TestBox user.

Maria Jose Herrera
Maria Jose Herrera
April 17, 2025
The Into the Box 2025 Agenda is LIVE and Done!

The Into the Box 2025 Agenda is LIVE and Done!

The wait is over! TheĀ official Into the Box 2025 agendaĀ is now live — and it's packed with high-impact sessions designed forĀ modern CFML and BoxLang developers. Whether you’re building APIs, modernizing legacy apps, diving into serverless, or exploring AI integrations,Ā this is the conference you’ve been waiting for.

Here’s a look at what you can expect — categorized by key topics to help you plan your learning journey, there’s something for everyone covering modern CFML tools and BoxLang:

Maria Jose Herrera
Maria Jose Herrera
April 15, 2025