> For the complete documentation index, see [llms.txt](https://ai.ortusbooks.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://ai.ortusbooks.com/advanced.md).

# Advanced

- [Working with Models](https://ai.ortusbooks.com/advanced/models.md): The comprehensive guide to working with AI models in BoxLang, covering creation, configuration, pipeline integration, parameters, options, and advanced usage.
- [Event System](https://ai.ortusbooks.com/advanced/events.md): Intercept, monitor, and customize AI operations at every stage with the module's 70 interception points.
- [Utility Functions](https://ai.ortusbooks.com/advanced/utilities.md): Utility functions for text processing, token management, and working with AI models.
- [Reference](https://ai.ortusbooks.com/advanced/reference.md): Reference documentation for BoxLang AI module
- [Built-In Functions Reference](https://ai.ortusbooks.com/advanced/reference/built-in-functions.md): Reference documentation for built-in functions in BoxLang AI module
- [MCP](https://ai.ortusbooks.com/advanced/reference/built-in-functions/mcp.md): Create a fluent MCP (Model Context Protocol) client for consuming external MCP servers.
- [MCPServer](https://ai.ortusbooks.com/advanced/reference/built-in-functions/mcpserver.md): Get or create an MCP (Model Context Protocol) server instance for registering and managing tools, resources, and prompts.
- [aiAgent](https://ai.ortusbooks.com/advanced/reference/built-in-functions/aiagent.md): Create an autonomous AI Agent that can reason, use tools, maintain memory, and execute multi-step tasks.
- [aiChat](https://ai.ortusbooks.com/advanced/reference/built-in-functions/aichat.md): Initiate an AI chat conversation against the default or custom AI Provider with a simple, synchronous interface.
- [aiChatAsync](https://ai.ortusbooks.com/advanced/reference/built-in-functions/aichatasync.md): Asynchronous version of aiChat() that returns a BoxLang Future for non-blocking AI requests.
- [aiChatRequest](https://ai.ortusbooks.com/advanced/reference/built-in-functions/aichatrequest.md): Create a reusable AI Chat Request object for building requests programmatically, managing conversations, or testing AI workflows.
- [aiChatStream](https://ai.ortusbooks.com/advanced/reference/built-in-functions/aichatstream.md): Stream AI responses in real-time with a callback function, ideal for UI updates and long responses.
- [aiChunk](https://ai.ortusbooks.com/advanced/reference/built-in-functions/aichunk.md): Chunk text into smaller, manageable segments for AI processing, embeddings, or semantic search.
- [aiDocuments](https://ai.ortusbooks.com/advanced/reference/built-in-functions/aidocuments.md): Main entry point for document loading in AI workflows — a fluent document loader for flexible configuration and execution.
- [aiEmbed](https://ai.ortusbooks.com/advanced/reference/built-in-functions/aiembed.md): Generate vector embeddings for text using AI providers, enabling semantic search, similarity comparison, and clustering.
- [aiFence](https://ai.ortusbooks.com/advanced/reference/built-in-functions/aifence.md): Wraps untrusted content in tamper-resistant boundary markers so the model treats it as data, never instructions.
- [aiGateway](https://ai.ortusbooks.com/advanced/reference/built-in-functions/aigateway.md): Resolves an IGateway instance by name — a gateway bx-ai ships in core, or one registered by an external gateway module.
- [aiDecisionStore](https://ai.ortusbooks.com/advanced/reference/built-in-functions/aidecisionstore.md): Creates an IDecisionStore — the backing store for durable human-approval grants used by Human-in-the-Loop.
- [aiGatewayRegistry](https://ai.ortusbooks.com/advanced/reference/built-in-functions/aigatewayregistry.md): Returns the singleton GatewayRegistry — the extension point external gateway modules use to make their gateway resolvable by aiGateway().
- [aiGatewaySession](https://ai.ortusbooks.com/advanced/reference/built-in-functions/aigatewaysession.md): Wires one AiAgent to one-or-more IGateway instances for inbound message handling, with a configurable dispatch policy for messages arriving on a busy thread.
- [aiMemory](https://ai.ortusbooks.com/advanced/reference/built-in-functions/aimemory.md): Create AI memory instances for storing conversation history, context, or knowledge bases.
- [aiMessage](https://ai.ortusbooks.com/advanced/reference/built-in-functions/aimessage.md): Build AI message structures fluently using a chainable API, with template interpolation and pipeline integration.
- [aiModel](https://ai.ortusbooks.com/advanced/reference/built-in-functions/aimodel.md): Create an AI Model runnable that wraps a service provider for use in pipelines — the pipeline-friendly version of aiService().
- [aiParallel](https://ai.ortusbooks.com/advanced/reference/built-in-functions/aiparallel.md): Create a parallel runnable that fans-out a single input to multiple named runnables concurrently and collects results into a named struct.
- [aiPopulate](https://ai.ortusbooks.com/advanced/reference/built-in-functions/aipopulate.md): Populate a class instance, struct, or array from JSON data or a struct — useful for structured AI output and deserialization.
- [aiService](https://ai.ortusbooks.com/advanced/reference/built-in-functions/aiservice.md): Get a reference to a registered AI service provider — the direct invocation interface for AI providers.
- [aiTokens](https://ai.ortusbooks.com/advanced/reference/built-in-functions/aitokens.md): Estimate token count for AI processing — useful for staying within model limits and estimating costs.
- [aiSkill](https://ai.ortusbooks.com/advanced/reference/built-in-functions/aiskill.md): Discover and load AI skills from a directory tree, a single file, or an inline skill definition.
- [aiGlobalSkills](https://ai.ortusbooks.com/advanced/reference/built-in-functions/aiglobalskills.md): Access the globally shared pool of AI skills that are automatically injected into every agent's system context.
- [aiSpeak](https://ai.ortusbooks.com/advanced/reference/built-in-functions/aispeak.md): Convert text to natural-sounding speech audio using an AI provider.
- [aiImage](https://ai.ortusbooks.com/advanced/reference/built-in-functions/aiimage.md): Generate images from prompts using supported AI providers.
- [aiTranscribe](https://ai.ortusbooks.com/advanced/reference/built-in-functions/aitranscribe.md): Transcribe audio from a file path, URL, or binary data into text using an AI provider.
- [aiTranslate](https://ai.ortusbooks.com/advanced/reference/built-in-functions/aitranslate.md): Translate audio from any language directly into English text using an AI provider.
- [aiWebSearch](https://ai.ortusbooks.com/advanced/reference/built-in-functions/aiwebsearch.md): BoxLang AI aiWebSearch() built-in function reference
- [aiWebSearchAsync](https://ai.ortusbooks.com/advanced/reference/built-in-functions/aiwebsearchasync.md): BoxLang AI aiWebSearchAsync() built-in function reference
- [aiAgentRegistry](https://ai.ortusbooks.com/advanced/reference/built-in-functions/aiagentregistry.md): Get the singleton global AIAgentRegistry instance for registering, resolving, and observing agents.
- [aiToolRegistry](https://ai.ortusbooks.com/advanced/reference/built-in-functions/aitoolregistry.md): Returns the singleton AIToolRegistry instance for registering, discovering, and resolving AI tools globally.
- [aiTool](https://ai.ortusbooks.com/advanced/reference/built-in-functions/aitool.md): Create callable function tools that AI agents can use to gather information or take actions.
- [aiTransform](https://ai.ortusbooks.com/advanced/reference/built-in-functions/aitransform.md): Create an AI Transform Runnable that applies transformation functions to data flowing through AI pipelines.
- [Production Deployment](https://ai.ortusbooks.com/advanced/production.md): Production deployment guide for BoxLang AI - monitoring, error handling, performance optimization, and best practices.
- [Security Guide](https://ai.ortusbooks.com/advanced/security.md): Security best practices for BoxLang AI - API key management, prompt injection prevention, data privacy, and compliance guidance.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://ai.ortusbooks.com/advanced.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
