Quick Start
Get MahanAI running in 10 seconds. Install with pip, run the command, and follow the onboarding wizard.
Installation & Launch
$ pip install mahanai
$ mahanaiThat's it. An onboarding wizard will guide you through:
- Picking a default model (Claude Haiku 4.5, Claude Sonnet 4.6, Codex, NVIDIA NIM, or Ollama)
- Setting up API keys (securely saved to
~/.config/mahanai/config.json) - Choosing a theme (midnight, light, or colorblind-friendly)
Guided Bootstrap (Optional)
For a fully automated setup that installs Python via uv, then MahanAI:
$ ./scripts/get-started.sh # Linux/macOS
$ .\scripts\get-started.ps1 # Windows (PowerShell)
$ pwsh .\scripts\get-started.ps1 # Windows (PowerShell Core)On macOS, you can also double-click scripts/get-started.command from Finder.
Your First Chat
Once launched, you'll see a full-width chat loop with:
- A gradient ASCII banner (tweens while you wait)
- A status line showing your model, effort level, and theme
- An approval-first tool runtime (all operations ask before executing)
Type your prompt and watch responses stream live. Press [A] to approve tool calls, [W] to always-allow, or [D] to deny.
Key Commands
low, medium, high, or very-high./cmd to fuzzy-search all commands, or save frequently-used combinations in /themrcfile~/project/.mahanairc config files for project-specific setups.
Installation
MahanAI is available on PyPI for Python 3.8+. Install once, launch anytime.
Via pip
$ pip install mahanaiUpgrade
$ pip install --upgrade mahanaiUninstall
$ pip uninstall mahanaiOnboarding
First launch runs a guided wizard that collects:
- Default model: Claude Haiku 4.5 is recommended for speed and cost.
- API keys: Stored securely in
~/.config/mahanai/config.json(or%APPDATA%\MahanAI\on Windows). Never transmitted. - Theme: Four built-in themes, plus support for custom
.maifiles.
Configuration Directory
- Linux/macOS:
~/.config/mahanai/config.json - Windows:
%APPDATA%\MahanAI\config.json
Override with MAHANAI_CONFIG_DIR environment variable.
Models & Providers
Switch between Claude, Codex, NVIDIA NIM, Ollama, and any OpenAI-compatible endpoint.
Built-in Providers
Claude (Anthropic)
Via Claude Code — sign in once, use all Claude models.
- Claude Haiku 4.5 (default) — fast, cheap, great for coding
- Claude Sonnet 4.6 — balanced performance & reasoning
- Claude Opus — powerful for complex reasoning
$ /mode claude # switch to Sonnet 4.6
$ /mode default # switch back to Haiku 4.5OpenAI Codex
Browser-based OAuth login, no API key needed.
$ /codex-login # opens browser
$ /mode codex # switch to Codex modelNVIDIA NIM
Llama 3.3 70B via NVIDIA's inference endpoint.
$ /api-key-nvidia your-api-key
$ /mode nvidia # switch to Llama 3.3 70BOllama
Run models locally. Install Ollama first, start a model, then add it to MahanAI:
$ ollama run llama2
$ /add-ollama llama2 localhost 11434Any OpenAI-compatible API
Point at LM Studio, vLLM, OpenRouter, or any /v1-compatible server:
$ /custom http://localhost:8000 my-model my-api-key
$ /mode my-model # switch to itSwitch Models
/mode claude, /mode ollama, etc.Commands Reference
60+ slash-prefixed commands for every scenario. Fuzzy-search them all with /cmd.
Model & Effort
↑↓ navigation./mode claude, /mode default.low, medium, high, very-high.Planning & Output
Branching & History
Computer Control
Themes & Display
midnight, light, midnight-cb, light-cb..mai theme file.Plugins & Store
/store install author/namespace.plugin..mmd plugin publicly..mmd plugin file.Cost & Analytics
Approvals
[W] Always-Allow rules.Keys & API
Custom Endpoints
localhost 11434.Workspace & Utilities
MAHANAI.md workspace context file.Configuration
Save API keys securely, configure per-project defaults, and set environment variables.
Configuration Directory
- Linux/macOS:
~/.config/mahanai/config.json - Windows:
%APPDATA%\MahanAI\config.json
Override location with MAHANAI_CONFIG_DIR environment variable.
Project Config (.mahanairc)
Place a .mahanairc file in any project root to auto-load context and plugins:
load(location="context.md" type=context)
load(location="plugins/my-plugin.mmd" type=mmd)
load(python-dev-kit)MahanAI scans upward from the current directory and applies the first .mahanairc it finds.
Environment Variables
| Variable | Purpose | Example |
|---|---|---|
MAHANAI_MODEL |
Default model override | claude, codex |
MAHANAI_API_KEY |
Override saved server key | sk-xxxx |
MAHANAI_STREAM |
Enable/disable response streaming | 0 to disable, default is 1 |
MAHANAI_CONFIG_DIR |
Override config directory | /etc/mahanai |
NO_COLOR |
Disable terminal colors | Any value to disable |
Command-Line Flags
$ mahanai --help # show all flags
$ mahanai --server --port 9000 # start gateway on port 9000
$ mahanai --server --type anthropic # serve Anthropic-compatible format
$ mahanai --compact # compact terminal mode
$ mahanai --no-stream # wait for full responseGateway Server
Run a local HTTP server that exposes all your providers behind one OpenAI- or Anthropic-compatible endpoint.
Start the Gateway
$ mahanai --server # OpenAI-compatible, port 8080
$ mahanai --server --port 9000 # Custom port
$ mahanai --server --type anthropic # Anthropic-compatible formatUse with Clients
Point any OpenAI-compatible tool at the gateway:
- Cursor, Continue.dev, Claude Code: Set API endpoint to
http://localhost:8080 - LM Studio, vLLM, Others: Set base URL to
http://localhost:8080/v1 - curl:
curl -X POST http://localhost:8080/v1/chat/completions -H "Content-Type: application/json" ...
Model Routing
Use the model field to select backend:
claude-haiku-4-5→ Anthropic Claude Haiku 4.5claude-sonnet-4-6→ Anthropic Claude Sonnet 4.6gpt-5→ OpenAI Codexllama-3.3-70b→ NVIDIA NIMmy-ollama-model→ Your Ollama instance
Endpoints
POST /v1/chat/completions— Standard OpenAI completionsPOST /v1/messages— Anthropic messages (when--type anthropic)GET /v1/models— List all available modelsGET /health— Health check
Browser UI
When the gateway is running, open http://localhost:8080 in your browser for a chat interface.
Plugin Development
Write .mmd plugin files to extend MahanAI with new slash commands.
Plugin Anatomy
A plugin is a .mmd (Mahan Markdown) file that declares commands and their handlers:
---
name: mycompany.my-plugin
displayName: My Cool Plugin
version: 1.0.0
description: Adds custom slash commands
permissions: [shell, file, web]
---
# /mycommand
Runs a custom operation.
* param1: string - description
* param2: optional number
## Implementation
This delegates to Claude Code or MahanAI itself.Frontmatter
name(required) — namespace.plugin-name (for store publishing)displayName— Human-readable plugin nameversion— Semantic version (e.g., 1.0.0)description— Short plugin descriptionpermissions— Array of requested permissions:shell,file,web, etc.
Declaring Commands
Each # /commandname heading defines a new slash command:
# /gitpush
Pushes changes to the remote, with guardrails.
* branch: string - branch name (defaults to current)
* message: string - optional custom message
## Implementation
Validates the branch, shows a diff, asks for confirmation.Built-in Integrations
- Claude Code: Delegate reasoning to Claude Code, which returns results to MahanAI
- Shell: Execute shell commands with MahanAI's approval-first runtime
- File I/O: Read/write files with inline diffs
- Web Search: Search the web and inject results into context
Publishing to the Store
$ /store upload path/to/my-plugin.mmdThis will:
- Create a public GitHub repository under
maifoundation/plugins/ - Push your
.mmdfile and create a release - Tag it so it appears in
/store browse
Installing Plugins
$ /store install mycompany/my-plugin
$ /store browse # see all available plugins
$ /plugin-load ./local-plugin.mmd # load from local fileTheme Development
Create custom terminal themes with .mai files. Define colors, gradients, and display names.
Theme Anatomy
A .mai theme file is a declarative config:
theme.name = my-theme
theme.pretty.name = My Custom Theme
// Colors
blue = #5B8DEF
gold = #F5C842
red = #FF5350
// Gradients
banner = gradient("blue -> purple -> gold")
// Text colors
ascii-art.default.color = gradient("blue -> gold")
message.ai.color = color("blue")
message.user.color = color("gold")
message.ai.name = text("assistant")
message.user.name = text("you")Built-in Themes
midnight— Dark blues and purpleslight— Light background, high contrastmidnight-cb— Colorblind-friendly dark versionlight-cb— Colorblind-friendly light version
Switch Themes
$ /themes midnight # switch to built-in theme
$ /theme-load mytheme.mai # load custom themeColor Functions
color("name")— Reference a named colorgradient("color1 -> color2 -> color3")— Define a gradienttext("string")— Display text literally
Available Properties
| Property | Description |
|---|---|
ascii-art.default.color |
Banner gradient |
message.ai.color |
MahanAI message text color |
message.user.color |
User message text color |
status.model.color |
Model name in status line |
approval.allow.color |
Allow button color |
approval.deny.color |
Deny button color |
API & Environment
Reference for API keys, environment variables, and advanced configuration.
API Keys
| Provider | Setup Method | Secure Storage |
|---|---|---|
| Claude | Install Claude Code and sign in | Handled by Claude Code, not MahanAI |
| NVIDIA NIM | /api-key-nvidia your-key |
~/.config/mahanai/config.json |
| Codex | /codex-login (browser OAuth) |
Tokens auto-refresh |
| Custom | /api-key your-key |
~/.config/mahanai/config.json |
Environment Variables (Full List)
| Variable | Type | Default | Description |
|---|---|---|---|
MAHANAI_MODEL |
string | claude |
Default model name |
MAHANAI_API_KEY |
string | (none) | Override saved API key |
MAHANAI_STREAM |
0 or 1 | 1 |
Enable response streaming |
MAHANAI_CONFIG_DIR |
path | ~/.config/mahanai |
Config directory override |
NO_COLOR |
flag | (none) | Disable terminal colors |
MAHANAI_LOG_LEVEL |
string | info |
debug, info, warning, error |
File Storage Locations
| File | Linux/macOS | Windows |
|---|---|---|
config.json |
~/.config/mahanai/ |
%APPDATA%\MahanAI\ |
history.jsonl |
~/.config/mahanai/ |
%APPDATA%\MahanAI\ |
branches/ |
~/.config/mahanai/branches/ |
%APPDATA%\MahanAI\branches\ |
plugins/ |
~/.config/mahanai/plugins/ |
%APPDATA%\MahanAI\plugins\ |
config.json Structure
{
"default_model": "claude-haiku-4-5",
"theme": "midnight",
"api_keys": {
"nvidia": "your-nvidia-key",
"custom": "your-custom-key"
},
"models": {
"ollama": {"host": "localhost", "port": 11434},
"lm_studio": {"url": "http://localhost:8000", "model": "model-name"}
},
"approvals": {
"shell": true,
"file": true
}
}Streaming (SSE)
By default, MahanAI streams responses using Server-Sent Events (SSE). This allows:
- Real-time token delivery while the model generates
- Format conversion end-to-end (OpenAI → Anthropic, etc.)
- Cancellation support via
Ctrl+C
Disable streaming:
$ MAHANAI_STREAM=0 mahanai
$ /stream off