EcoCoder (https://api.leanlm.ai) lets you run existing coding tools—Claude Code, Codex CLI, OpenCode, Cline, pi, or direct HTTPS SDKs—against LeanLM’s flat-rate coding endpoint while scoping Claude Code and pi per terminal tab (or adding a named provider entry in ~/.codex/config.toml for Codex CLI). Every Standard turn bills at one deterministic schedule ($0.30/1M uncached input, $0.03/1M cached input, $1.20/1M output & reasoning, flat across context lengths; optional --flex flag available for unattended overnight CI) and returns measured GPU board energy in Joules via Loupe (see Ledger v4.0).
Model, Context, Rate Limits & Protocol Matrix
Qualify EcoCoder before signup: every supported client protocol, model alias, context limit, and preview quota is published below.
| Specification | Published Contract |
|---|---|
| Canonical model & stability | ecocoder (alias leanlm-eco). Legacy IDs (ecocoder-turbo, leanlm-turbo) normalize server-side to the same unified ecocoder endpoint. Pinned to dated releases (Ledger v4.0 · 2026-11-24) with zero silent quality-degrading swaps (SKU stability policy; 60-day notice on breaking changes). |
| First-class languages | Python (.py), TypeScript (.ts, .tsx), JavaScript (.js, .jsx, .mjs, .cjs), Java (.java), plus companion SQL, Shell, YAML, TOML, JSON, HTML/CSS, and Dockerfiles. |
| Wire routes | Anthropic Messages (POST /v1/messages), OpenAI Chat (POST /v1/chat/completions), and Codex Responses (POST /v1/responses). |
| Context & output limits | 128,000-token total context window (prompt + max_tokens ≤ 128,000); 32,768 default max output tokens (up to 65,536 when requested on smaller prompts, leaving up to 62,464 input tokens). Server-side multi-turn context management on api.leanlm.ai folds single oversized tool stdout blocks above 24 KB so long agent loops stay within context. |
| Streaming, tools & JSON | Full SSE streaming (stream: true), multi-turn parallel & sequential tool/function calling across all three wire protocols, and structured JSON (response_format: json_object / json_schema). |
| Prefix cache policy | Automatic prefix matching (≥1,024 tokens) billed at $0.03/1M Standard / $0.024/1M --flex (90% off input, $0 cache-write fee, typical warm prefix retention 5–15 min). |
| GPU board energy telemetry | Loupe samples NVIDIA NVML board sensors across 100% of turns (GPU board only: 3,600 kJ = 1 kWh; excludes host CPU, DRAM, network, and cooling), returning X-LeanLM-Energy-Joules and X-LeanLM-Cost-Usd headers on non-streaming responses and recording final SSE stream receipts to ecocoder stats --run-id and the portal. |
| Rate & concurrency limits | Evaluation preview keys ($10 allocation, $0 collected): 60 RPM, 2,000,000 TPM, 4 concurrent streams. Commercial team agreements are currently gated to our Design-Partner Waitlist (hello@leanlm.ai). |
Step 1: Choose Direct HTTPS (Zero Sync) or Checksum-Verified CLI
Choose your connection boundary upfront:
- Direct HTTPS (zero repository file staging, any OS): Point your SDK,
ANTHROPIC_BASE_URL(https://api.leanlm.ai), OpenAIOPENAI_BASE_URL(https://api.leanlm.ai/v1), or Codexconfig.tomlstraight atapi.leanlm.ai. Only the prompt and tool-result messages constructed by your client are transmitted over TLS in volatile memory. - Optional
ecocoderCLI helper (macOS & Linux, Python 3 stdlib, 0 pip packages): Adds per-tab isolation,--max-usdsession guards,ecocoder stats, localecocoder sync-previewinspection, and ephemeral repository file staging (≤1 MiB/file, 15 MiB max; see Data Handling below).
mkdir -p ~/.local/bin && tmp=$(mktemp) && \
curl -fsSL https://api.leanlm.ai/ecocoder -o "$tmp" && \
(printf "6ee1768b76c59ae326200a33cb587809a4f0bf4bd1078c73213871151ce11f8a %s\n" "$tmp" | shasum -a 256 -c - 2>/dev/null || \
printf "6ee1768b76c59ae326200a33cb587809a4f0bf4bd1078c73213871151ce11f8a %s\n" "$tmp" | sha256sum -c -) && \
chmod +x "$tmp" && mv "$tmp" ~/.local/bin/ecocoder && \
export PATH="$HOME/.local/bin:$PATH" && ecocoder login && ecocoder check
Want to inspect which local files the CLI wrapper would stage before launching an agent? Run ecocoder sync-preview inside your repo (0 network calls).
Direct HTTPS First Request (No Wrapper Required)
Load your eco_live_... key into the current shell without writing it to shell history, then verify directly over HTTPS using either Anthropic Messages (x-api-key or Authorization: Bearer) or OpenAI Chat Completions (both default to the fast Standard lane):
# Prompt silently in zsh or bash so your key never enters shell history
printf "EcoCoder API key: " >&2 && IFS= read -rs ECOCODER_API_KEY && echo && export ECOCODER_API_KEY
# Anthropic wire protocol (/v1/messages) — zero bulk workspace staging
curl -sS https://api.leanlm.ai/v1/messages \
-H "Content-Type: application/json" \
-H "x-api-key: $ECOCODER_API_KEY" \
-H "anthropic-version: 2023-06-01" \
-d '{
"model": "ecocoder",
"max_tokens": 512,
"messages": [{"role": "user", "content": "Write a pytest check for empty Retry-After headers."}]
}'
# OpenAI wire protocol (/v1/chat/completions) on Standard (~2s-4s/turn)
# Optional unattended overnight/CI (-20%): add -H "X-LeanLM-Flex: eco"
curl -sS https://api.leanlm.ai/v1/chat/completions \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $ECOCODER_API_KEY" \
-d '{
"model": "ecocoder",
"max_tokens": 512,
"messages": [{"role": "user", "content": "Return a minimal TypeScript guard for finite numbers."}]
}'
Responses include protocol-native usage fields (input_tokens, cache_read_input_tokens, output_tokens on /v1/messages; prompt_tokens, prompt_tokens_details.cached_tokens, completion_tokens on /v1/chat/completions). Non-streaming responses carry Loupe receipt headers (X-LeanLM-Cost-Usd, X-LeanLM-Energy-Joules); streamed sessions write receipts to ecocoder stats --run-id and the portal.
Step 2: Flat Pricing & Execution Lanes
EcoCoder bills every turn at one deterministic rate schedule across all context lengths with zero escalation surcharges and zero cache-write fees. Every request executes on contracted US NVIDIA NVML-instrumented GPUs:
| Lane | Published Flat Rate ($ / 1M Tokens) | When to Use |
|---|---|---|
Standardecocoder |
$0.30 uncached in · $0.03 cached in · $1.20 out Applies identically to visible output + thinking/reasoning tokens (zero separate thinking surcharge) · $0.18/brownfield repo · $0.052/short PR |
Default for live terminal sessions. Direct interactive dispatch in Claude Code, Codex CLI, OpenCode, Cline, and pi (~2.4s p50 turn latency on 33k OSS turns, ~4.0s p50 on 74k brownfield turns; TTFT not separately logged; 55.1s median short OSS PR, 271.0s median brownfield Python repo; 8.9× lower cost than Opus 5.5 and 28% cheaper than Haiku 5.5 on brownfield repos). |
Flex (−20% CI)--flex / X-LeanLM-Flex: eco |
$0.24 uncached in · $0.024 cached in · $0.96 out 0.80× across all tokens · unattended overnight/CI only |
Unattended overnight & background CI (−20% price). Best-effort async queue: matches Standard (~2–8s/turn) when capacity is open, or holds up to ~60s/turn under load (5×–18× longer multi-turn wall time, and NVML GPU board energy can rise during holds). Intended for unattended overnight/background CI jobs with ≥15–30m timeouts (≥60m on large repos), not interactive sessions. |
Step 3: Connect Your Coding Agent
Adopt EcoCoder incrementally either by delegating bounded subtasks from your current lead session (Option A) or by scoping a terminal tab directly to api.leanlm.ai (Options B–D):
--flex only on unattended overnight CI runs).
Option A — Claude Code Subagent & Headless Delegation
Keep your interactive Claude Code lead session on Opus or Sonnet and offload implementation, refactoring, and test-repair tasks to @ecocoder (written to .claude/agents/ecocoder.md) on the fast Standard lane (add --flex only for unattended overnight/CI runs):
cd /path/to/your/repo
# Install .claude/agents/ecocoder.md on Standard (~2s-4s/turn) with --max-usd 1.50
ecocoder install-subagent --max-usd 1.50
# Or delegate a bounded interactive task via your local claude or pi CLI
ecocoder delegate "Add boundary timeout tests in retry.py and fix failures" --max-usd 1.00
Note: ecocoder delegate invokes an installed local claude or pi agent for multi-turn file editing and test execution (if neither CLI is installed on a bare CI runner, it falls back to a single-turn HTTP completion).
Option B — Claude Code (claude CLI)
Launching via ecocoder claude sets ANTHROPIC_BASE_URL for that child process only, leaving your normal claude configuration in every other terminal tab untouched (for zero workspace staging, run ANTHROPIC_BASE_URL=https://api.leanlm.ai ANTHROPIC_API_KEY="$ECOCODER_API_KEY" claude --model ecocoder directly):
cd /path/to/your/repo
ecocoder claude
# Unattended overnight/CI only (-20% price; matches Standard when open or holds up to ~60s/turn under load):
ecocoder claude --flex -- -p "Refactor parser.ts and run tests"
Option C — pi (@mariozechner/pi-coding-agent)
Launch pi scoped to EcoCoder on Standard for the current terminal session:
cd /path/to/your/repo
ecocoder pi
Option D — Codex CLI (POST /v1/responses, Direct HTTPS / Zero Workspace Staging)
Add a named ecocoder provider block in ~/.codex/config.toml (your default Codex provider stays unchanged unless you pass -c model_provider="ecocoder"):
[model_providers.ecocoder]
name = "EcoCoder"
base_url = "https://api.leanlm.ai/v1"
env_key = "ECOCODER_API_KEY"
wire_api = "responses"
supports_websockets = false
# Load from ~/.ecocoder/key (0600) so the secret never enters shell history
export ECOCODER_API_KEY="$(tr -d '[:space:]' < ~/.ecocoder/key)"
codex -c model_provider="ecocoder" -m ecocoder
Option E — OpenCode (opencode.json, Direct HTTPS / Zero Workspace Staging)
Add a leanlm OpenAI-compatible provider entry to ~/.config/opencode/opencode.json (or project-local opencode.json) and keep ECOCODER_API_KEY in your environment:
{
"$schema": "https://opencode.ai/config.json",
"provider": {
"leanlm": {
"npm": "@ai-sdk/openai-compatible",
"name": "LeanLM EcoCoder",
"options": {
"baseURL": "https://api.leanlm.ai/v1",
"apiKey": "{env:ECOCODER_API_KEY}"
},
"models": {
"ecocoder": {
"name": "EcoCoder",
"limit": { "context": 128000, "output": 32768 }
}
}
}
},
"model": "leanlm/ecocoder"
}
Option F — Cline in VS Code (Direct HTTPS / Zero Workspace Staging)
In VS Code Cline Settings, select API Provider: OpenAI Compatible and configure the fields directly:
API Provider: OpenAI Compatible
Base URL: https://api.leanlm.ai/v1
API Key: $ECOCODER_API_KEY
Model ID: ecocoder
Context Window: 128000
Max Output: 32768
Step 4: View Account & Per-Session GPU Board Joules
Run ecocoder stats to view your cumulative account GPU board energy in Joules / Watt-hours, or pass --run-id "$RUN_ID" to inspect a specific session:
ecocoder stats
ecocoder stats --run-id "${RUN_ID:-xjq-cp4-cp5}"
Data Handling, Ephemeral CLI Staging, Subprocessors & Security
- Legal entity & zero training: LeanLM is operated by Stellar Content Inc. (d/b/a LeanLM). We never train, fine-tune, or distill models on customer source code, prompts, or completions. Inference runs in volatile memory on contracted NVIDIA NVML GPU nodes located in the United States (US-Central / US-East), never third-party commercial chat APIs.
- Direct HTTPS (zero repo staging) vs. optional CLI ephemeral staging: Connecting directly to
https://api.leanlm.aiviaANTHROPIC_BASE_URL,OPENAI_BASE_URL, or Codexconfig.toml(Option D / Direct HTTPS) processes prompt and tool turns in volatile memory and never stages repository files. When you launch via the optionalecocoder claude,ecocoder pi, orecocoder delegatewrapper, the CLI runsgit ls-files --cached --others --exclude-standard(falling back to a filtered directory walk outside git) and stages eligible tracked & untracked non-ignored files matching.py, .ts, .tsx, .js, .jsx, .mjs, .cjs, .java, .go, .rs, .json, .toml, .yaml, .yml(≤1 MiB/file, 15 MiB max; skipping.git, .venv, node_modules, target, dist, build, .aws, .ssh, .gnupgand.env*, *.pem, *.key, id_rsa*, id_ed25519*, *secret*, *credential*, .npmrc, .pypirc, .netrc) into a tenant-isolated ephemeral workspace deleted on session exit (and swept within 24 hours on abnormal disconnect). Runecocoder sync-previewlocally to inspect the exact file manifest with zero network calls, or use Direct HTTPS for repos with inline secrets. - 90-day numeric receipt retention & subprocessors: Gateway ledger rows store numeric token counts, USD amounts, timings, and GPU board Joules (never prompt or code bodies) for 90 days and are deleted earlier on request to hello@leanlm.ai. Subprocessors (full table & retention windows): Cloudflare, Inc. (edge TLS routing, gateway compute, encrypted billing ledger, and ephemeral workspace storage), WorkOS, Inc. (Key Portal SSO authentication), Brevo (transactional signup emails), PostHog, Inc. (
identified_onlyweb analytics onleanlm.aimarketing pages only; zero API traffic), and our Contracted US Datacenter GPU Host (volatile in-memory NVIDIA NVML inference; vendor named under NDA / upon request). - Security, SOC 2 status & commercial waitlist: See our Security page (TLS 1.3, AES-256 at rest, SHA-256 hashed
eco_live_...keys, vulnerability reports at security@leanlm.ai) and Status page. SOC 2 Type II status: Not yet certified (planned for H2 2027). Paid commercial team agreements and dedicated single-tenant ZDR deployments are gated to our Design-Partner Waitlist at hello@leanlm.ai during the evaluation preview.
HTTP Status & Retry Guidance
| Status | Meaning & Client Action |
|---|---|
401 |
Missing, mistyped, or revoked eco_live_... key. Run ecocoder login followed by ecocoder check. |
402 |
Promotional evaluation allocation ($10 public preview / $25 invited reviewer) or per-run --max-usd guard reached. Email hello@leanlm.ai to request an evaluation extension or join the commercial design-partner waitlist. |
411 |
Metered preview keys require a bounded Content-Length header on inference POSTs. |
429 / 503 |
Rate-limit window (429) or transient GPU pool reset (503). Honor the returned Retry-After header with jittered exponential backoff (1 s, 2 s, 4 s); check /status if persistent. |
Developer & Design-Partner Evaluation Preview · $0 Collected
Request a $10 eco_live_... preview key
Enter your work email for a provisioned $10.00 promotional EcoCoder evaluation key with live NVML GPU board Joule telemetry. No credit card accepted.