menta
Minimal Rust library for non-UI LLM/AI primitives.
menta is being prepared for an initial 0.0.1 crates.io release.
Installation
Add menta to your Cargo.toml:
[]
= "0.0.1"
= { = "1", = ["macros", "rt-multi-thread"] }
tokio is only needed if you call async helpers like generate_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
examples/generate_text.rs: basic text generationexamples/stream_text.rs: streaming eventsexamples/generate_object.rs: structured output withGenerateTextRequest::<Type>examples/embeddings.rs: embeddings and similarity rankingexamples/tool.rs: Tokio example for#[derive(Tool)]with automatic execution ingenerate_textexamples/agent.rs: interactive agent-style REPL example
Run one example with:
The agent example runs as a loop and accepts prompts until exit or quit.
Publishing Notes
- Crate version:
0.0.1 - License:
MIT OR Apache-2.0 - Repository:
https://github.com/KABBOUCHI/menta - Publish order:
menta_derivefirst, thenmenta
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: