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

ContentBox v6.1 Released

ContentBox v6.1 Released

In this release, we're thrilled to unveil a series of significant enhancements and upgrades to ContentBox designed to elevate your experience and considerably improve system performance. Our team has focused on integrating the latest CommandBox migrations and ColdBox Core, which ensures that the core system continues to operate with maximum efficiency and stability. This upgrade is part of our ongoing commitment to maintaining a cutting-edge platform that meets the evolving needs of our users.

Luis Majano
Luis Majano
March 19, 2025
Ortus Monthly Recap - Jan/Feb

Ortus Monthly Recap - Jan/Feb

Ortus Solutions is kicking off 2025 with major milestones, from the highly anticipated Into the Box 2025 to groundbreaking advancements in BoxLang and key industry event appearances at Jfokus and DevNexus 2025. With new product releases, enhanced compatibility, and exclusive discounts, we’re equipping developers with the tools they need to build faster, smarter, and more efficiently.Let’s dive into the latest updates shaping the future of modern web development!

Maria Jose Herrera
Maria Jose Herrera
March 18, 2025
BoxLang 1.0.0 RC2 Launched

BoxLang 1.0.0 RC2 Launched

We’re entering the final stretch of our pre-releases, and we couldn’t be more excited to introduce RC2! 🚀 This release marks a major leap in performance and compatibility, the result of over six months of intensive development. Beyond enhanced stability and seamless integration, RC2 delivers game-changing performance optimizations that push the boundaries of efficiency. Get ready for our fastest, most refined release yet!

Luis Majano
Luis Majano
March 14, 2025