Mojentic
A modern LLM integration framework for Rust with full feature parity across Python, Elixir, and TypeScript implementations.
Mojentic provides a clean abstraction over multiple LLM providers with tool support, structured output generation, streaming, and a complete event-driven agent system.
๐ Features
- ๐ Multi-Provider Support: OpenAI and Ollama gateways
- ๐ Type-Safe: Leverages Rust's type system for safe LLM interactions
- โก Async-First: Built on Tokio for efficient async operations
- ๐ ๏ธ Tool System: Extensible tool calling with automatic recursive execution
- ๐ Structured Output: Generate type-safe structured data with serde
- ๐ Streaming: Async streaming with
Pin<Box<dyn Stream>> - ๐ Tracer System: Complete observability for debugging and monitoring
- ๐ค Agent System: Event-driven multi-agent coordination with ReAct pattern
- ๐ฆ 24 Examples: Comprehensive examples demonstrating all features
๐ฆ Installation
Add Mojentic to your Cargo.toml:
[]
= "3.0"
= { = "1", = ["full"] }
๐ง Prerequisites
To use Mojentic with local models, you need Ollama installed and running:
- Install Ollama from ollama.ai
- Pull a model:
ollama pull qwen3:32b - Verify it's running:
ollama list
๐ฏ Quick Start
use *;
use Arc;
async
๐ Documentation
- User Guide: mdBook documentation
- API Reference:
cargo doc --no-deps --all-features --open
Build documentation locally:
# Build API docs
# Build the mdBook
๐๏ธ Architecture
Mojentic is structured in three layers:
Layer 1: LLM Integration
LlmBroker- Main interface for LLM interactionsLlmGatewaytrait - Abstract interface for LLM providersOllamaGateway/OpenAiGateway- Provider implementationsChatSession- Conversational session managementTokenizerGateway- Token counting with tiktoken-rsEmbeddingsGateway- Vector embeddings- Comprehensive tool system with 10+ built-in tools
Layer 2: Tracer System
TracerSystem- Thread-safe event recordingEventStore- Event persistence and querying- Correlation ID tracking with
Arcsharing - LLM call, response, and tool events
Layer 3: Agent System
AsyncDispatcher- Event routingRouter- Event-to-agent routingBaseLlmAgent/AsyncLlmAgent- LLM-powered agentsIterativeProblemSolver- Multi-step reasoningSimpleRecursiveAgent- Self-recursive processingSharedWorkingMemory- Agent context sharing withRwLock- ReAct pattern implementation
๐งช Examples
๐ง Development
# Build
# Test
# Format
# Lint
# Security audit
๐ License
MIT License - see LICENSE
Credits
Mojentic is a Mojility product by Stacey Vetzal.