Free Pi AI Coding Agent · Open Source

FreeRouter-Pi.
Every gateway, one terminal.

Run an open-source terminal coding agent routed through FreeRouter's unified LLM gateway. Pull your live provider catalog with /model and optionally offset compute costs with contextual AdsRouter ads.

$npm install -g freerouter-pi@latest
$npx freerouter-pi@latest
freerouter-pi — zsh
┬───┬   ╔═╗╦═╗╔═╗╔═╗╦═╗╔═╗╦ ╦╔╦╗╔═╗╦═╗   ╔═╗╦
 │ │    ╠╣ ╠╦╝║╣ ║╣ ╠╦╝║ ║║ ║ ║ ║╣ ╠╦╝ ═ ╠═╝║
 ┴ ╰─   ╚  ╩╚═╚═╝╚═╝╩╚═╚═╝╚═╝ ╩ ╚═╝╩╚═   ╩  ╩

        v0.1.5 · 48 models synced from FreeRouter
        /model switch · /keys api keys · /ad open · /exit quit

> Add rate-limit retry middleware to src/gateway.ts

  ● Read  src/gateway.ts (118 lines)
  ● Edit  src/gateway.ts (+24 -3)
  ● Bash  npm test
  ✓ 19 passed, 0 failed (312ms)

  Done. Added exponential backoff with jitter on HTTP 429/503
  and updated retry tests in tests/gateway.test.ts.
[Sponsored] Vercel — Deploy Any Frontend Framework with Zero Config
Ship preview deployments on every pull request · Learn more ↗ (/ad to open)
freerouter/claude-sonnet-5.5 12.4k / 200k · ~/my-app (main)

Quickstart

Up and coding in three steps.

Zero lock-in, bring your own FreeRouter key, and switch models or gateways without touching a config file.

01

Install FreeRouter-Pi

Install globally with npm or run directly with npx — always pinned to @latest so you get the newest gateway and AdsRouter support.

npm install -g freerouter-pi@latest
npx freerouter-pi@latest
02

Connect your FreeRouter key

Grab a key at app.freerouter.com. Launching freerouter-pi walks you through first-run onboarding automatically, or export your key in your shell:

export FREEROUTER_API_KEY="fr_..."
03

Add AdsRouter (Optional)

Sign in at adsrouter.ai to grab your Property Key (ar_pub_...) and Property Secret (ar_sec_...). Set them via env vars or live in-app with /keys.

Ads appear contextually below the editor after agent responses — click the terminal link or run /ad to open.

export ADSROUTER_PROPERTY_KEY="ar_pub_..." ADSROUTER_PROPERTY_SECRET="ar_sec_..."

Unified LLM Gateway + Live Sync

Change providers on the backend. /model stays in sync.

FreeRouter sits behind your single API key as a unified LLM gateway router. Connect OpenRouter, Vercel AI Gateway, Cloudflare AI Gateway, or direct model providers on the backend — with automatic failover, traffic splits, and model remaps.

Whenever you add, swap, or reconfigure providers in the FreeRouter dashboard, simply run /model inside freerouter-pi. It pulls your updated live model catalog straight from FreeRouter — zero CLI reconfiguration, no hand-edited models.json, and no restarts.

Want to see how manual configuration compares? Read our Pi + FreeRouter guide.

Connect every LLM gateway once

Bring your own keys across OpenRouter, Vercel, Cloudflare, Anthropic, OpenAI, and more. FreeRouter mediates every call behind one fr_... key.

Automatic /model catalog sync

Add a new provider or remap a model on the FreeRouter backend, then type /model in the TUI. Your newly available models appear immediately with zero local config edits.

Failover & routing without touching your CLI

Switch from priority failover to percentage splits or cheapest-route arbitrage in the FreeRouter dashboard while your coding session keeps running uninterrupted.

Extensible Blueprint

Build your own ad-supported AI dev harness.

FreeRouter-Pi is more than a ready-to-run CLI — it is an open-source reference blueprint for pairing a multi-gateway LLM router with contextual native monetization.

FreeRouter + AdsRouter out of the box

Pair FreeRouter's unified inference routing with AdsRouter to subsidize token spend for your team, community, or developer tool. Ads are fetched asynchronously after agent turns and never block inference or fail a prompt.

Extend via pi extensions or fork it

Drop in custom pi extensions for your own tools, slash commands, and workflows — or fork github.com/niyogi/freerouter-pi (MIT) to ship your own branded, ad-supported AI coding harness in minutes.

Start coding with FreeRouter-Pi.

One command to launch. One key for every LLM gateway. Optional AdsRouter when you want to offset compute.

$npx freerouter-pi@latest