menta
Minimal Rust library for non-UI LLM/AI primitives.
menta is published on crates.io at 0.0.4.
Workspace
crates/menta: core library cratecrates/derive: proc-macro crate for#[derive(Tool)]crates/agent: interactive CLI agent package (menta-cli)
Installation
Add menta to your Cargo.toml:
[]
= "0.0.4"
= { = "1", = ["macros", "rt-multi-thread"] }
tokio is only needed if you call async helpers like generate_text or stream_text.
Included
- Provider registry with string model ids like
openai/gpt-4.1-mini - Inventory-based provider discovery
- Built-in providers:
mock,openai,anthropic - Unified message model with content parts:
ModelMessage,Part - Text generation:
generate_text - Type-driven outputs with
GenerateTextRequest<T> - Streaming events:
stream_text schemars-based typed schemas inferred fromT- Derive-based tools:
#[derive(Tool)],ToolExecute,ToolSchema - Embeddings and similarity helpers:
embed,embed_many,cosine_similarity,rank_by_similarity - OpenAI examples via
OPENAI_API_KEY
Text requests can use GenerateTextRequest::new(). Typed outputs can use GenerateTextRequest::<T>::typed().
For builder ergonomics, single typed tools can be added with .tool::<MyTool>().
Quick Start
use ;
async
Examples
crates/menta/examples/generate_text.rs: basic text generationcrates/menta/examples/stream_text.rs: streaming eventscrates/menta/examples/generate_object.rs: structured output withGenerateTextRequest::<Type>crates/menta/examples/embeddings.rs: embeddings and similarity rankingcrates/menta/examples/tool.rs: Tokio example for#[derive(Tool)]with automatic execution ingenerate_textcrates/menta/examples/stream_tools.rs: streaming a tool-call turn and inspectingFinish.partscrates/menta/examples/agent.rs: interactive agent-style REPL examplecrates/agent: installable CLI project (menta-clipackage)
Run one example with:
The agent example runs as a loop and accepts prompts until exit or quit.
Run or install the CLI agent project:
Agent flags:
Agent commands:
/help
/new
/model [provider/model]
/pwd
/tools
!<shell-command>
Publishing Notes
- Crate version:
0.0.4 - License:
MIT OR Apache-2.0 - Repository:
https://github.com/KABBOUCHI/menta - Publish order:
menta_derivefirst, thenmenta, thenmenta-cli
Design Notes
- This is intentionally a core-only library, not a UI/chat app.
- The API stays small and dependency-light.
- The mock provider is still used in tests through the same registry as real providers.
Verification
Run: