Quick Start

Get MahanAI running in 10 seconds. Install with pip, run the command, and follow the onboarding wizard.

Installation & Launch

$ pip install mahanai $ mahanai

That'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

/models
Switch models interactively with arrow keys and Enter.
/effort high
Set reasoning depth: low, medium, high, or very-high.
/plan on
Outline approach before every response.
/cost
See session token usage and estimated spend.
/help
List all 60+ commands.
Tip: Use /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 mahanai

Upgrade

$ pip install --upgrade mahanai

Uninstall

$ pip uninstall mahanai

Onboarding

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 .mai files.

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.5

OpenAI Codex

Browser-based OAuth login, no API key needed.

$ /codex-login # opens browser $ /mode codex # switch to Codex model

NVIDIA NIM

Llama 3.3 70B via NVIDIA's inference endpoint.

$ /api-key-nvidia your-api-key $ /mode nvidia # switch to Llama 3.3 70B

Ollama

Run models locally. Install Ollama first, start a model, then add it to MahanAI:

$ ollama run llama2 $ /add-ollama llama2 localhost 11434

Any 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 it

Switch Models

/models
Interactive picker with arrow keys and Enter.
/mode <name>
Quick-switch: /mode claude, /mode ollama, etc.
MAHANAI_MODEL=claude
Set default model via environment variable.

Commands Reference

60+ slash-prefixed commands for every scenario. Fuzzy-search them all with /cmd.

Model & Effort

/models
Interactive model selector with ↑↓ navigation.
/mode <name>
Quick-switch to a model: /mode claude, /mode default.
/effort <level>
Set reasoning: low, medium, high, very-high.

Planning & Output

/plan on
Outline approach before every response.
/plan off
Turn off plan mode.
/auto on
Skip approval prompts (use with caution).
/auto off
Require approval for all tool calls.

Branching & History

/branch save <name>
Snapshot conversation state for later restore.
/branch load <name>
Restore a saved branch.
/branch list
Show all saved branches.
/history search <query>
Search saved chat sessions by keyword.
/memory add <text>
Save a persistent memory note (cross-session).
/shell-history inject
Add recent bash/zsh history to context.

Computer Control

/interact
Enable computer control with screenshots, mouse, and keyboard.
/interact remove
Disable computer control and remove the feature.

Themes & Display

/themes <name>
Switch theme: midnight, light, midnight-cb, light-cb.
/theme-load <path>
Load a custom .mai theme file.

Plugins & Store

/store browse
Browse the GitHub-backed plugin store.
/store install <name>
Install plugin: /store install author/namespace.plugin.
/store upload <path>
Publish your .mmd plugin publicly.
/plugin-load <path>
Load a local .mmd plugin file.

Cost & Analytics

/cost
Session token usage and estimated spend.

Approvals

/approvals
List all [W] Always-Allow rules.
/approvals clear
Wipe all saved approval rules.

Keys & API

/api-key [key]
Save server key (or omit for hidden prompt).
/api-key clear
Remove saved key.
/api-key-nvidia <key>
Set NVIDIA NIM key.
/codex-login
Sign in to OpenAI Codex via browser OAuth.
/codex-logout
Sign out of Codex.

Custom Endpoints

/add-ollama <name> [host] [port]
Add Ollama instance. Defaults: localhost 11434.
/custom <url> [model] [key]
Point at OpenAI-compatible server (LM Studio, vLLM, OpenRouter).

Workspace & Utilities

/init
Generate MAHANAI.md workspace context file.
/cmd
Fuzzy-search all commands.
/help
Show this reference.
/exit, /quit
Exit MahanAI.

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 response

Gateway 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 format

Use 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.5
  • claude-sonnet-4-6 → Anthropic Claude Sonnet 4.6
  • gpt-5 → OpenAI Codex
  • llama-3.3-70b → NVIDIA NIM
  • my-ollama-model → Your Ollama instance
Format Conversion: The gateway automatically converts between OpenAI and Anthropic formats, including streaming (SSE) in both directions. Your client doesn't need to know about backend differences.

Endpoints

  • POST /v1/chat/completions — Standard OpenAI completions
  • POST /v1/messages — Anthropic messages (when --type anthropic)
  • GET /v1/models — List all available models
  • GET /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 name
  • version — Semantic version (e.g., 1.0.0)
  • description — Short plugin description
  • permissions — 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.mmd

This will:

  1. Create a public GitHub repository under maifoundation/plugins/
  2. Push your .mmd file and create a release
  3. 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 file

Theme 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 purples
  • light — Light background, high contrast
  • midnight-cb — Colorblind-friendly dark version
  • light-cb — Colorblind-friendly light version

Switch Themes

$ /themes midnight # switch to built-in theme $ /theme-load mytheme.mai # load custom theme

Color Functions

  • color("name") — Reference a named color
  • gradient("color1 -> color2 -> color3") — Define a gradient
  • text("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