Overview
Core building blocks for AI agents and pipelines in BoxLang - your guide to mastering AI development
Welcome to the heart of BoxLang AI! This section introduces the essential building blocks you'll use to create intelligent applications. Whether you're building chatbots, autonomous agents, or complex AI workflows, these components are your toolkit.
🎯 What You'll Learn
BoxLang AI uses a runnable pipeline architecture - think of it as composable LEGO blocks for AI:
┌─────────────┐ ┌─────────────┐ ┌─────────────┐ ┌─────────────┐
│ Messages │───▶│ AI Model │───▶│ Transform │───▶│ Result │
│ Template │ │ (OpenAI) │ │ (Extract) │ │ │
└─────────────┘ └─────────────┘ └─────────────┘ └─────────────┘Each component:
🔗 Chains easily - Connect pieces with
.to()♻️ Reuses workflows - Define once, run many times
🧩 Composes freely - Mix and match as needed
🎯 Stays flexible - Swap providers without refactoring
📚 Learning Path
We recommend learning the components in this order for the best experience:
START HERE
↓
┌──────────────────────────────────────────────────────────────┐
│ 1️⃣ Models - Connect to AI providers (OpenAI, Claude, etc.) │
└──────────────────────────────────────────────────────────────┘
↓
┌──────────────────────────────────────────────────────────────┐
│ 2️⃣ Messages - Build conversations with templates │
└──────────────────────────────────────────────────────────────┘
↓
┌──────────────────────────────────────────────────────────────┐
│ 3️⃣ Chatting - High-level conversational AI APIs │
└──────────────────────────────────────────────────────────────┘
↓
┌──────────────────────────────────────────────────────────────┐
│ 4️⃣ Streaming - Real-time responses for better UX │
└──────────────────────────────────────────────────────────────┘
↓
┌──────────────────────────────────────────────────────────────┐
│ 5️⃣ Structured Output - Extract typed data from responses │
└──────────────────────────────────────────────────────────────┘
↓
┌──────────────────────────────────────────────────────────────┐
│ 6️⃣ Tools - Enable AI to call your functions │
└──────────────────────────────────────────────────────────────┘
↓
┌──────────────────────────────────────────────────────────────┐
│ 7️⃣ Skills - Reusable AI capabilities │
└──────────────────────────────────────────────────────────────┘
↓
┌──────────────────────────────────────────────────────────────┐
│ 8️⃣ Tool Registry - Central tool management │
└──────────────────────────────────────────────────────────────┘
↓
┌──────────────────────────────────────────────────────────────┐
│ 9️⃣ Memory - Maintain conversation context │
└──────────────────────────────────────────────────────────────┘
↓
┌──────────────────────────────────────────────────────────────┐
│ 🔟 Agents - Autonomous AI with memory & tools │
└──────────────────────────────────────────────────────────────┘
↓
┌──────────────────────────────────────────────────────────────┐
│ 1️⃣1️⃣ Pipelines - Build composable AI workflows │
└──────────────────────────────────────────────────────────────┘
↓
┌──────────────────────────────────────────────────────────────┐
│ 1️⃣2️⃣ Transformers - Data processing in pipelines │
└──────────────────────────────────────────────────────────────┘
↓
┌──────────────────────────────────────────────────────────────┐
│ 1️⃣3️⃣ Middleware - Intercept & modify pipeline execution │
└──────────────────────────────────────────────────────────────┘
↓
┌──────────────────────────────────────────────────────────────┐
│ 1️⃣4️⃣ Vector Memory - Semantic search for RAG apps │
└──────────────────────────────────────────────────────────────┘
↓
┌──────────────────────────────────────────────────────────────┐
│ 1️⃣5️⃣ Document Loaders - Import content from any source │
└──────────────────────────────────────────────────────────────┘
↓
┌──────────────────────────────────────────────────────────────┐
│ 1️⃣6️⃣ RAG - Complete retrieval-augmented generation workflow │
└──────────────────────────────────────────────────────────────┘
↓
┌──────────────────────────────────────────────────────────────┐
│ 1️⃣7️⃣ Audio/Speech - Voice synthesis & recognition │
└──────────────────────────────────────────────────────────────┘
↓
┌──────────────────────────────────────────────────────────────┐
│ 1️⃣8️⃣ Image Generation - AI-powered visual content │
└──────────────────────────────────────────────────────────────┘
↓
┌──────────────────────────────────────────────────────────────┐
│ 1️⃣9️⃣ Web Search - Real-time web data retrieval │
└──────────────────────────────────────────────────────────────┘Quick Paths:
🚀 Building a chatbot? → Start with Models → Messages → Memory → Agents
🔎 Building research agents? → Start with Tools → Web Search → Memory → Agents
📊 Extracting data? → Start with Models → Structured Output → Transformers → Pipelines
🔍 Building RAG? → Start with Document Loaders → Vector Memory → RAG → Agents
🛠️ Creating workflows? → Start with Models → Transformers → Pipelines → Agents
🎤 Adding voice? → Start with Audio/Speech → Agents
🖼️ Generating images? → Start with Image Generation → Agents
🔌 Extending AI? → Start with Skills → Tool Registry → Middleware
🧱 Core Components
1️⃣ AI Models
What: Direct AI provider integrations (OpenAI, Claude, Gemini, Ollama, etc.)
When to use: Every AI application - this is your foundation
Quick example:
Key concepts:
Provider abstraction
Parameter configuration
Return formats (text, JSON, XML, raw)
Pipeline composition
2️⃣ Messages
What: Reusable message templates with dynamic placeholders and multi-modal content
When to use: Repeated prompts, variable content, organized conversations
Quick example:
Key concepts:
Role-based messages (system, user, assistant)
Variable binding with
${}placeholdersMultimodal content (images, audio, documents)
Message reusability
3️⃣ Chatting
What: High-level conversational AI interface with session management and structured output
When to use: Building chatbots, interactive assistants, multi-turn conversations
Quick example:
Key concepts:
Session-based chat
Service-level abstraction
Structured output via returnFormat
Async and streaming variants
4️⃣ Streaming
What: Real-time token-by-token response delivery
When to use: Interactive UIs, chatbots, long responses
Quick example:
Key concepts:
Callback functions
Progressive UI updates
Streaming with agents
Performance optimization
5️⃣ Structured Output
What: Extract typed data from AI responses into classes/structs
When to use: Form extraction, data parsing, type-safe results
Quick example:
Key concepts:
Class population
JSON schema generation
Array extraction
Validation
6️⃣ Tools
What: Functions that AI can call to access data or perform actions
When to use: Real-time data, external APIs, database queries
Quick example:
Key concepts:
Function calling
Parameter schemas
Tool registration
Auto-registered built-ins (e.g.,
webSearch@bxai,speak@bxai)Autonomous invocation
7️⃣ Skills
What: Reusable, shareable capabilities that encapsulate prompts, tools, and logic
When to use: Encapsulating expertise, modular agent design, sharing capabilities
Quick example:
Key concepts:
Skill definition and registration
Tool integration
Reusable expertise
Agent skill composition
8️⃣ Tool Registry
What: Central registry for managing, discovering, and registering AI-callable tools
When to use: Dynamic tool registration, lifecycle management, tool discovery
Quick example:
Key concepts:
Tool registration and discovery
Lifecycle management
Global vs scoped registries
9️⃣ Memory
What: Conversation context management strategies
When to use: Multi-turn conversations, context preservation
Quick example:
Key concepts:
Memory types (windowed, summary, session, file)
Context limits
Memory persistence
Multiple memory strategies
🔟 Agents
What: Autonomous AI entities with memory, tools, and reasoning
When to use: Complex workflows, multi-step tasks, autonomous behavior
Quick example:
Key concepts:
Autonomous reasoning
Tool selection
Memory integration
Sub-agents
1️⃣1️⃣ Pipelines
What: Composable AI workflows - chain models, messages, and transformers
When to use: Complex multi-step workflows, reusable templates, data processing flows
Quick example:
Key concepts:
Runnable interface (IAiRunnable)
Fluent chaining with
.to()Template reusability
Multi-step workflows
Data flow and transformations
1️⃣2️⃣ Transformers
What: Data processing steps in pipelines
When to use: Format conversion, data extraction, custom logic
Quick example:
Key concepts:
Pipeline transformations
Data extraction
Format conversion
Custom processors
1️⃣3️⃣ Middleware
What: Intercept and modify pipeline execution at any stage
When to use: Logging, monitoring, rate limiting, security, input/output augmentation
Quick example:
Key concepts:
Pipeline interception
Context modification
Pre/post processing
Middleware chaining
1️⃣4️⃣ Vector Memory
What: Semantic search through conversation history
When to use: RAG applications, knowledge bases, semantic retrieval
Quick example:
Key concepts:
Embedding generation
Similarity search
Vector stores (Chroma, Pinecone, OpenSearch, etc.)
RAG workflows
1️⃣5️⃣ Document Loaders
What: Import content from files, directories, URLs, databases, and APIs
When to use: Building knowledge bases, RAG systems, data ingestion pipelines
Quick example:
Key concepts:
12+ built-in loaders (Text, Markdown, CSV, JSON, XML, PDF, etc.)
Automatic metadata extraction
Chunking strategies
Directory traversal
Direct vector memory integration
1️⃣6️⃣ RAG (Retrieval-Augmented Generation)
What: Complete workflow for answering questions using your documents
When to use: Q&A systems, documentation search, knowledge bases, chatbots with domain expertise
Quick example:
Key concepts:
Document loading and chunking
Embedding generation
Vector similarity search
Context injection
Source attribution
Hybrid search (keyword + semantic)
1️⃣7️⃣ Audio/Speech
What: Text-to-speech, speech-to-text, and audio translation capabilities
When to use: Voice interfaces, accessibility, audio content generation
Quick example:
Key concepts:
Multi-provider TTS
Speech recognition
Audio translation
Voice configuration
1️⃣8️⃣ Image Generation
What: AI-powered image generation and manipulation
When to use: Creating visuals, design assets, image analysis
Quick example:
Key concepts:
Prompt-based generation
Image response formats
Agent tool integration
Multi-provider support
1️⃣9️⃣ Web Search
What: Web search capabilities for AI agents and pipelines
When to use: Real-time information retrieval, research agents, fact-checking
Quick example:
Key concepts:
Multi-provider search
Agent tool integration
Async search support
Result parsing
🔗 Understanding Pipelines
Pipelines are the foundation of BoxLang AI - they connect components into workflows:
Basic Pipeline Flow
The .to() Method
Chain components together:
Pipeline Benefits
Example - Reusable Pipeline:
🎨 Common Patterns
Pattern 1: Simple Q&A
Pattern 2: Templated Conversations
Pattern 3: Agent with Tools
Pattern 4: RAG (Retrieval Augmented Generation)
Pattern 5: Multi-Step Processing
🚀 Quick Start Examples
Example 1: Your First Pipeline (3 lines)
Example 2: Chatbot with Memory (5 lines)
Example 3: Function Calling (8 lines)
Example 4: Data Extraction (6 lines)
💡 Tips for Success
Start simple - Master models and messages before agents
Test incrementally - Build pipelines step by step
Reuse components - Create libraries of templates and agents
Monitor costs - Use appropriate models for each task
Read the guides - Each component page has detailed examples
Ready to build? Start with AI Models →
Last updated