Open source, written in Nim
The AI stack for Nim
Libraries for native AI apps
nimgent, nimwire, and nimterm are Nim libraries for model calls, agents, RAG, MCP servers, and terminal UIs. Compile them to a small native binary: fast startup, low memory, no interpreter runtime. Nimlet is the coding agent built from the same libraries.
import nimgent
import nimgent/providers/openai
let model = openAI(getEnv("OPENAI_API_KEY")).model("gpt-4o-mini")
let response = generateText(
model,
system = "You are a concise assistant.",
prompt = "Explain why the sky is blue in one sentence.")
echo response.text
The same typed generation API works across providers, including OpenRouter, OpenAI,
Anthropic,
Gemini, Mistral, Hyper, OpenCode,
and ChatGPT-backed Codex through /login.
Install with
nimble install nimgent, nimble install nimwire, or
nimble install nimterm.
Coding agent
Fast to start, light on memory, no CPU until you ask
Run Nimlet in a repository, describe the change you want, and it inspects files, edits them, runs the commands you approve, and keeps the session. The native binary starts quickly, uses little memory, and the CPU stays idle while it waits. nimgent handles models and tools, nimwire handles MCP, and nimterm handles the terminal UI.
$ nimlet
> Fix the failing parser test and run the focused test.
plan Inspect the parser and its tests
read src/parser.nim, tests/parser_test.nim
edit Apply the smallest safe change
bash nimble test parser
done The focused test passes.
-
Small process
Compiled to native code, not interpreted. Startup is fast, memory use stays low, meaning you can run multiple Nimlet processes without a heavy runtime per instance.
-
Blocks when waiting
It waits on you, a provider, or a subprocess. No polls, no timers, no idle CPU.
-
Your provider, your keys
Requests go straight to the provider you pick. Credentials stay in your environment or in
~/.nimlet/auth.json. -
Shell needs approval
Reads, searches, and workspace edits run freely. Shell commands and extensions ask the first time, with per-session and per-project grants.
Wired providers: OpenRouter, OpenAI, Anthropic,
Gemini, Mistral, Hyper, OpenCode,
and ChatGPT-backed Codex through /login.
$ export OPENROUTER_API_KEY=your-key
$ cd /path/to/your/project
$ nimlet
Libraries
Three packages you can use without nimlet
Each library stands on its own. Use nimgent for model calls and agents, nimwire for an MCP server, or nimterm for a terminal UI. nimlet is one application that links all three.
-
nimgent
nimble install nimgent
A Nim SDK for language-model apps and agents. One typed API for generation, streaming, tools, structured output, agents, conversations, retrieval, and MCP clients. Swap providers without rewriting the call site.
- Same generation code across OpenAI, Anthropic, Gemini, OpenRouter, Mistral, Hyper, OpenCode, and your own provider
- Streaming text, typed tools, and structured output
- Agents, conversations, embeddings, and retrieval
-
nimwire
nimble install nimwire
MCP server primitives for Nim. Declare typed tools, resources, and prompts, then serve them over stdio, Streamable HTTP, or WebSocket.
- MCP over stdio, Streamable HTTP, and WebSocket
- Tools, prompts, resources, URI templates, and completion
- Authorization, deadlines, cancellation, progress, and metrics
-
nimterm
nimble install nimterm
Terminal agent UI primitives for Nim. A testable canvas, layout, themes, Markdown, widgets, and the lifecycle events an agent transcript needs.
- Cells, layout, themes, and Markdown rendering
- Text, panel, input, menu, and question widgets
- Agent lifecycle events, with POSIX and Windows backends