bilibiliBoxLang AI

BoxLang AI is a powerful library for building fluent and scalable AI applications with a unified LLM API.

ColdBox has deep integrations with the BoxLang AI library in order to build AI applications and services. All you need to do is install the bx-ai module in your web application and you will have a powerful library for building fluent and scalable AI applications with ColdBox.

circle-info

You can find the complete AI SDK docs here: https://ai.ortusbooks.com/arrow-up-right

Introduction

Welcome to the BoxLang AI Library - your unified gateway to integrating AI capabilities into any JVM application. This library provides an elegant, easy-to-use API for interacting with multiple AI providers, from simple chat requests to complex multi-agent systems.

πŸ™‹ What is BoxLang AI?

BoxLang AI is a comprehensive library that brings enterprise-grade artificial intelligence capabilities to the JVM ecosystem. Whether you're building chatbots, content generators, code assistants, RAG systems, or complex AI workflows, this module provides everything you need.

spinner

✨ Key Features

  • 🌐 Multi-Provider Support: Work with OpenAI, Claude, Gemini, Grok, Groq, DeepSeek, Ollama, and more

  • πŸ”„ Unified API: One consistent interface across all providers

  • πŸ‘₯ Multi-Tenant Memory: Enterprise-grade isolation with userId and conversationId across all 20 memory types

  • 🎨 Multimodal Content: Process images, audio, video, and documents alongside text

  • 🏠 Local AI Support: Run models locally with Ollama for privacy and offline use

  • πŸ”— AI Pipelines: Chain operations together for complex multi-step workflows

  • ⚑ Streaming Responses: Get real-time responses as they're generated

  • πŸ› οΈ Tool Integration: Enable AI to call functions and access real-time data

  • πŸš€ Async Support: Non-blocking operations for better performance

  • πŸ“ Template System: Create reusable prompts with dynamic placeholders

  • πŸ€– AI Agents: Autonomous agents with memory, tools, and reasoning

  • πŸ“„ Document Loaders: Load and process various file formats for RAG

  • 🧠 Vector Memory: Semantic search with 12 vector database integrations

πŸ“‘ Supported Providers

BoxLang supports a variety of AI providers out of the box. You can also create custom providers by following our Custom Provider Guide.

Provider
Type
Best For

Bedrock

Cloud

AWS enterprise, multi-model (Claude, Titan, Llama, Mistral)

Claude

Cloud

Long context, detailed analysis

Cohere

Cloud

Embeddings, multilingual, chat, tool calling

DeepSeek

Cloud

Code generation, reasoning

Docker Desktop

Local

Docker-managed models, easy local AI

Gemini

Cloud

Google integration, multimodal

Grok

Cloud

Real-time data, Twitter integration

Groq

Cloud

Ultra-fast inference, LPU architecture

HuggingFace

Cloud

Open-source models, community-driven

Ollama

Local

Privacy, offline use, no API costs

OpenAI

Cloud

General purpose, GPT-5, etc

OpenRouter

Gateway

Access multiple models through one API

Perplexity

Cloud

Research, citations, factual answers

Voyage

Cloud

State-of-the-art embeddings, specialized for RAG

πŸ—ƒοΈ Supported Memory Types

BoxLang AI provides 20+ memory types for conversation history and semantic search. All memory types support multi-tenant isolation with userId and conversationId.

Memory Type
Vector
Best For
Storage
Multi-Tenant

Windowed

❌

Recent N messages, simple context

In-memory

βœ…

Summary

❌

Long conversations with summarization

In-memory

βœ…

Session

❌

Web sessions, survives page refresh

HTTP Session

βœ…

File

❌

Persistent storage, file-based

File System

βœ…

Cache

❌

Fast retrieval, distributed cache

CacheBox

βœ…

JDBC

❌

Enterprise database storage

Any JDBC DB

βœ…

BoxVector

βœ…

Development, prototyping

In-memory

βœ…

Chroma

βœ…

Python integration, local dev

ChromaDB

βœ…

Postgres

βœ…

Existing PostgreSQL infrastructure

PostgreSQL

βœ…

MySQL

βœ…

Existing MySQL 9+ infrastructure

MySQL

βœ…

OpenSearch

βœ…

AWS integration, enterprise search

OpenSearch

βœ…

TypeSense

βœ…

Fast typo-tolerant search

TypeSense

βœ…

Pinecone

βœ…

Production cloud-native

Pinecone Cloud

βœ…

Qdrant

βœ…

Self-hosted, high performance

Qdrant

βœ…

Weaviate

βœ…

GraphQL, knowledge graphs

Weaviate

βœ…

Milvus

βœ…

Enterprise, massive scale

Milvus

βœ…

Hybrid

βœ…

Recent + semantic combined

Vector + Standard

βœ…

πŸ“– Learn More: Standard Memory Guide Β· Vector Memory Guide

πŸ“‹ Supported Document Loaders

BoxLang AI provides 12 document loaders for importing content from various sources into standardized Document format for RAG workflows.

Loader
File Types
Best For
Features

TextLoader

.txt, .text

Plain text files

Simple text ingestion

MarkdownLoader

.md, .markdown

Markdown documents

Header splitting, code removal

HTMLLoader

.html, .htm

HTML pages

Tag extraction, script/style removal

CSVLoader

.csv

Tabular data

Row/column modes, filtering

JSONLoader

.json

JSON data

Field extraction, array handling

XMLLoader

.xml

XML documents

XPath queries, attribute extraction

PDFLoader

.pdf

PDF documents

Text extraction, page splitting

LogLoader

.log

Log files

Pattern matching, timestamp parsing

HTTPLoader

URLs

Web content

HTTP/S, headers, authentication

FeedLoader

RSS/Atom

RSS/Atom feeds

Feed parsing, item extraction

SQLLoader

SQL queries

Database records

JDBC datasources, query execution

DirectoryLoader

Folders

Batch loading

Recursive scanning, type detection

WebCrawlerLoader

Websites

Web crawling

Multi-page, depth control, link following

Key Features:

  • βœ… Fluent API - Chain configuration methods

  • βœ… Memory Integration - Direct ingestion with toMemory()

  • βœ… Automatic Chunking - Split large documents

  • βœ… Async Support - Load documents asynchronously

  • βœ… Multi-Memory Fan-out - Ingest to multiple vector stores

  • βœ… Transform/Filter - Apply transformations during load

πŸ“– Learn More: Document Loaders Guide Β· Custom Loaders

πŸš€ Use Cases

  • πŸ’¬ Chatbots: Build conversational interfaces with memory and context

  • ✍️ Content Generation: Create articles, documentation, marketing copy

  • πŸ’» Code Assistance: Generate, review, and explain code

  • πŸ“Š Data Analysis: Extract insights from text and structured data

  • πŸ“„ Document Processing: Analyze PDFs, contracts, and reports

  • πŸŽ₯ Media Analysis: Process images, audio, and video content

  • 🌍 Translations: Multi-language content translation

  • πŸ“‹ Summarization: Condense long documents intelligently

  • ❓ Question Answering: Build knowledge bases and FAQs with RAG

  • πŸ”„ Custom Workflows: Multi-step AI processing pipelines


πŸ“– Quick Start

πŸŽ“ Getting Started

Perfect for beginners - get up and running quickly

πŸ’¬ Simple AI Interactions

Learn basic chat, streaming, and structured output

πŸ”— AI Pipelines

Build complex workflows with agents, memory, and tools

πŸ€– AI Agents

Build reusable and autonomous agents, sub-agents, and much more.


πŸ”§ Built-In Functions (BIFs)

BoxLang AI provides a comprehensive set of BIFs for different AI operations. You can see all of our BIF reference documentation here: BIF Reference.

πŸ’¬ Chat & Conversation

BIF
Purpose
Return Type
Example Use Case

aiChat()

Simple one-shot chat request

String

Quick Q&A, content generation

aiChatAsync()

Non-blocking chat request

Future

Background processing, parallel requests

aiChatRequest()

Build structured chat requests

AiChatRequest

Complex requests with tools

aiChatStream()

Real-time streaming responses

void

Live chat, progressive output

aiService()

Get AI service instances

Service

Multi-provider management

πŸ—οΈ Pipeline Components

BIF
Purpose
Return Type
Example Use Case

aiAgent()

Create AI agents

AiAgent

Autonomous assistants, multi-turn

aiMessage()

Build message pipelines

AiMessage

Reusable prompts, templates

aiModel()

Create model runnables

AiModel

Pipeline integration

aiTransform()

Create data transformers

Transformer

Pipeline data processing

aiTool()

Define callable functions

Tool

Real-time data, function calling

🧠 Memory & Context

BIF
Purpose
Return Type
Example Use Case

aiMemory()

Create conversation or vector memory

Memory

Context-aware conversations, RAG, semantic search

πŸ“„ Document Processing

BIF
Purpose
Return Type
Example Use Case

aiDocuments()

Load documents from sources

Array/Loader

Document processing, RAG

πŸ”’ Utilities

BIF
Purpose
Return Type
Example Use Case

aiChunk()

Split text into chunks

Array

Processing large documents

aiEmbed()

Generate vector embeddings

Array/Struct

Semantic search, similarity

aiPopulate()

Populate a class instance, struct, or array from JSON data or struct.

Any

This is useful for testing, custom workflows, or working with cached AI responses.

aiTokens()

Estimate token counts

Numeric

Cost estimation, limits

βš™οΈ MCP (Model Context Protocol)

BIF
Purpose
Return Type
Example Use Case

MCP()

Connect to MCP servers

MCPClient

External tools, resources

MCPServer()

Create MCP server instances

MCPServer

Expose tools to agents


πŸš€ Quick Examples

πŸ’¬ Simple Chat

🎨 Simple Chat with Parameters

πŸ”— Build a Pipeline

⚑ Stream Responses

πŸ“¦ Get JSON Responses

πŸ› οΈ Use AI Tools

πŸ”’ Generate Embeddings

πŸ“„ Load Documents

πŸ€– Create an Agent


πŸ†˜ Need Help?

πŸ“š Resources

  • πŸ“– Full Documentation: Explore all sections above for comprehensive guides

  • πŸ’‘ Examples: Check the /examples folder for runnable code samples

  • πŸ” BIF Reference: See reference/built-in-functions/ for detailed function docs

  • πŸ“¦ Module Components: Explore main-components/ for in-depth component guides

🀝 Community & Support

πŸŽ“ Learning Paths

  1. 🌱 Beginners: Start with Quick Start β†’ Basic Chatting β†’ Examples

  2. πŸ—οΈ Builders: Learn Pipelines β†’ Memory β†’ Tools

  3. πŸš€ Advanced: Explore Agents β†’ RAG β†’ Custom Components

Last updated

Was this helpful?