Providers
LeanCTL supports 7+ AI providers out of the box. Use local models for free, or connect your own cloud API keys with Pro.
Overview
| Provider | Type | Tier | Best For |
|---|---|---|---|
| Ollama | ollama | Free | Local, private, no API costs |
| LM Studio | lmstudio | Free | Local with GUI model management |
| Anthropic | anthropic | Pro | Claude models — best coding quality |
| OpenAI | openai | Pro | GPT models — versatile, fast |
| DeepSeek | deepseek | Pro | Affordable, strong reasoning |
| Groq | groq | Pro | Ultra-fast inference |
| OpenRouter | openrouter | Pro | Access to 100+ models via one API |
Local Providers (Free)
Ollama
The easiest way to get started for free. Install Ollama, pull a model, and go.
# Install Ollama
# macOS: brew install ollama
# Linux: curl -fsSL https://ollama.ai/install.sh | sh
# Pull a model
ollama pull qwen3.5:27b # recommended for coding
ollama pull gemma4:e2b # Google's Gemma 4
# Configure via wizard
leanctl init Or add directly to ~/.leanctl/config.toml:
[[providers]]
name = "local"
type = "ollama"
model = "qwen3.5:27b"
base_url = "http://localhost:11434" # default Remote Ollama
Connect to an Ollama instance running on another machine:
[[providers]]
name = "murat"
type = "ollama"
model = "qwen3.5:27b"
base_url = "http://192.168.1.100:11434" local = true if your Ollama runs on a public server to bypass the Pro tier check.
LM Studio
LM Studio provides a GUI for downloading and running models. Start the local server, then configure:
[[providers]]
name = "lmstudio"
type = "lmstudio"
model = "qwen3.5-27b"
base_url = "http://localhost:1234" # default Cloud Providers (Pro)
Cloud providers require LeanCTL Pro ($9/month). You bring your own API key — LeanCTL does not proxy your requests.
Anthropic (Claude)
[[providers]]
name = "claude"
type = "anthropic"
model = "claude-sonnet-4-20250514"
api_key_env = "ANTHROPIC_API_KEY" Supported models: claude-sonnet-4-20250514, claude-opus-4-20250514, and all Claude 3.x models.
Get your API key: console.anthropic.com
OpenAI (GPT)
[[providers]]
name = "gpt"
type = "openai"
model = "gpt-4.1"
api_key_env = "OPENAI_API_KEY" Supported models: gpt-4.1, gpt-4.1-mini, o4-mini, and all OpenAI chat models.
Get your API key: platform.openai.com
DeepSeek
[[providers]]
name = "deepseek"
type = "deepseek"
model = "deepseek-chat"
api_key_env = "DEEPSEEK_API_KEY"
base_url = "https://api.deepseek.com/v1" Get your API key: platform.deepseek.com
Groq
[[providers]]
name = "groq"
type = "groq"
model = "llama-3.3-70b-versatile"
api_key_env = "GROQ_API_KEY"
base_url = "https://api.groq.com/openai/v1" Get your API key: console.groq.com
OpenRouter
[[providers]]
name = "openrouter"
type = "openrouter"
model = "anthropic/claude-sonnet-4"
api_key_env = "OPENROUTER_API_KEY"
base_url = "https://openrouter.ai/api/v1" Access 100+ models through a single API. Get your key: openrouter.ai
Custom OpenAI-Compatible Endpoints
Any endpoint that implements the OpenAI chat completions API works with LeanCTL:
[[providers]]
name = "my-server"
type = "openai"
model = "my-model"
base_url = "https://my-server.com/v1"
api_key = "my-key"
local = true # set true to bypass tier check for self-hosted This works with: vLLM, text-generation-inference, LocalAI, llama.cpp server, and any other OpenAI-compatible API.
Switching Providers
Switch providers and models at any time:
In the TUI
/model # open model picker (Ctrl+L)
/model claude-sonnet-4-20250514 # switch model
/model claude/claude-sonnet-4 # switch provider + model
/connect list # show all configured providers
/connect test # test current connection From the CLI
leanctl --model ollama/qwen3.5:27b
leanctl --model claude-sonnet-4-20250514
leanctl models API Key Security
Best practices for managing API keys:
- Environment variables (recommended): Set keys in your shell profile and reference them with
api_key_env. - Config file: Store directly in
config.tomlwithapi_key. The file is in your home directory (~/.leanctl/), but is not encrypted. - .env file: LeanCTL loads
.envfrom your project root. Add.envto.gitignore.
api_key in the config file, ensure ~/.leanctl/config.toml has restricted permissions (chmod 600).
Free vs Pro
LeanCTL determines if a provider is "local" or "cloud" automatically:
- Local (Free):
ollamatype,lmstudiotype, or any provider withlocal = true, or abase_urlpointing tolocalhost,127.0.0.1, or private IP ranges. - Cloud (Pro):
anthropic,openai,deepseek,groq,openroutertypes without local override.
To upgrade to Pro:
leanctl register # free beta registration
leanctl subscribe # or subscribe at leanctl.com/#pricing
leanctl login # enter your API key Streaming & Usage Tracking
All providers support streaming responses. LeanCTL tracks token usage per turn:
| Provider | Streaming | Usage Tracking |
|---|---|---|
| Anthropic | SSE (Server-Sent Events) | Input, output, thinking, cache creation, cache read tokens |
| OpenAI | SSE streaming | Input, output, reasoning tokens |
| Ollama | NDJSON lines | Eval count (output tokens) |
| Others | OpenAI-compatible SSE | Standard usage fields |
View costs with /cost in the TUI or leanctl stats from the command line.
Context Windows
LeanCTL automatically detects the context window for known models:
| Model Family | Context Window |
|---|---|
| Claude (all) | 200,000 tokens |
| GPT-4.1 | 1,000,000 tokens |
| GPT-4o / GPT-4 Turbo | 128,000 tokens |
| o1 / o3 / o4 | 200,000 tokens |
| DeepSeek | 128,000 tokens |
| Llama 3.x | 128,000 tokens |
| Qwen | 131,072 tokens |
| Gemma 4 | 128,000–256,000 tokens |
| Mistral | 32,000 tokens |
| Default (unknown) | 128,000 tokens |
Override with the context_window field in your provider definition if needed.