API Reference
Classes
Section titled “Classes”AIConfig
Section titled “AIConfig”Complete configuration for Lexigram Intelligence.
Attributes: name: Configuration name (default: “ai”) enabled: Whether AI features are enabled llm: LLM configuration vector: Vector store configuration rag: RAG pipeline configuration governance: AI governance configuration observability: Observability configuration subsystems: Dynamic configuration for third-party AI subsystems
Return the provider class for this config.
Block insecure AI configurations in production.
AIModule
Section titled “AIModule”Core AI layer: LLM orchestration, RAG pipelines, and governance.
Call configure to configure the AI subsystem. Sub-modules such as LLMModule and RAGModule may be imported independently for more granular control.
Usage
from lexigram.ai.config import AIConfigfrom lexigram.ai.llm.config import ClientConfig
@module( imports=[ AIModule.configure( AIConfig(llm=ClientConfig(provider="openai", model="gpt-4o")) ) ])class AppModule(Module): passfrom lexigram.ai.config import AIConfigfrom lexigram.ai.llm.config import ClientConfig
@module( imports=[ AIModule.configure( AIConfig(llm=ClientConfig(provider="openai", model="gpt-4o")) ) ])class AppModule(Module): passCreate an AIModule with explicit configuration.
| Parameter | Type | Description |
|---|---|---|
| `config` | Any | None | AIConfig or ``None`` for framework defaults. **kwargs: Additional keyword arguments forwarded to AIProvider. |
| Type | Description |
|---|---|
| DynamicModule | A DynamicModule descriptor. |
Return a no-op AIModule for testing.
Registers all AI sub-modules with their testing stubs: agents, LLM, RAG, memory, prompts, skills, sessions, feedback, governance, and guards with minimal side effects.
| Type | Description |
|---|---|
| DynamicModule | A DynamicModule with all AI sub-modules in testing configuration. |
AIProvider
Section titled “AIProvider”Provider for registering Intelligence services with Lexigram DI container.
This provider orchestrates sub-providers (LLMProvider, VectorProvider, RAGProvider) and is solely responsible for monitoring, governance, and AIProvider-specific services (RAGCache).
Example
from lexigram.app import Applicationfrom lexigram.ai import AIModule
app = Application()app.add_module(AIModule.configure(...))
# LLMClientProtocol is now available for injection@Controller("/chat")class ChatController:def __init__(self, llm: LLMClientProtocol):self.llm = llmInitialize the Intelligence Provider.
| Parameter | Type | Description |
|---|---|---|
| `config` | AIConfig | None | Initial AI configuration (optional; can be set by orchestrator) |
| `llm_config` | ClientConfig | None | LLM-specific configuration (overrides config.llm) |
| `vector_config` | VectorConfig | None | Vector-specific configuration (overrides config.vector) |
| `name` | str | Provider name |
Get the current AI configuration (from override or container-provided config).
Get the resolved database provider (set during boot).
Get the resolved cache backend (set during boot).
Register services with the DI container.
Registers monitoring, governance, and config singletons directly. Delegates LLM, Vector, and RAG service registration to the respective sub-providers.
| Parameter | Type | Description |
|---|---|---|
| `container` | ContainerRegistrarProtocol | The Lexigram DI container |
Chat with optional tool calling. Delegates to LLM sub-provider’s client.
Start the intelligence provider.
Performs async I/O only for AIProvider-specific services: RAGCache. Sub-providers handle their own async initialization during register().
| Parameter | Type | Description |
|---|---|---|
| `container` | ContainerResolverProtocol | The DI container |
Clean up resources on application shutdown.
Check provider health by aggregating sub-provider and local service checks.
| Type | Description |
|---|---|
| HealthCheckResult | Structured HealthCheckResult with component health information |