| Crates.io | mojentic |
| lib.rs | mojentic |
| version | 1.0.0 |
| created_at | 2025-11-28 02:30:43.588593+00 |
| updated_at | 2025-11-28 02:30:43.588593+00 |
| description | An LLM integration framework for Rust |
| homepage | https://svetzal.github.io/mojentic-ru |
| repository | https://github.com/svetzal/mojentic-ru |
| max_upload_size | |
| id | 1954711 |
| size | 2,656,852 |
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.
Pin<Box<dyn Stream>>Add Mojentic to your Cargo.toml:
[dependencies]
mojentic = "1.0.0"
tokio = { version = "1", features = ["full"] }
To use Mojentic with local models, you need Ollama installed and running:
ollama pull qwen3:32bollama listuse mojentic::prelude::*;
use std::sync::Arc;
#[tokio::main]
async fn main() -> Result<()> {
let gateway = Arc::new(OllamaGateway::new());
let broker = LlmBroker::new("qwen3:32b", gateway, None);
let messages = vec![
LlmMessage::user("What is the capital of France?"),
];
let response = broker.generate(&messages, None, None).await?;
println!("Response: {}", response);
Ok(())
}
cargo doc --no-deps --all-features --openBuild documentation locally:
# Build API docs
cargo doc --no-deps --all-features
# Build the mdBook
mdbook build book
open book/book/index.html
Mojentic is structured in three layers:
LlmBroker - Main interface for LLM interactionsLlmGateway trait - Abstract interface for LLM providersOllamaGateway / OpenAiGateway - Provider implementationsChatSession - Conversational session managementTokenizerGateway - Token counting with tiktoken-rsEmbeddingsGateway - Vector embeddingsTracerSystem - Thread-safe event recordingEventStore - Event persistence and queryingArc sharingAsyncDispatcher - Event routingRouter - Event-to-agent routingBaseLlmAgent / AsyncLlmAgent - LLM-powered agentsIterativeProblemSolver - Multi-step reasoningSimpleRecursiveAgent - Self-recursive processingSharedWorkingMemory - Agent context sharing with RwLockcargo run --example simple_llm
cargo run --example structured_output
cargo run --example tool_usage
cargo run --example streaming
cargo run --example chat_session
cargo run --example tracer_demo
cargo run --example async_llm
cargo run --example iterative_solver
# Build
cargo build
# Test
cargo test
# Format
cargo fmt
# Lint
cargo clippy --all-targets --all-features -- -D warnings
# Security audit
cargo deny check
MIT License - see LICENSE
Mojentic is a Mojility product by Stacey Vetzal.