Using OpenRouter Free Models with Pi Coding Agent
I wanted to run Pi without paying per token, so I pointed it at OpenRouter’s free tier. Here’s how I wired it up.
The Setup
Edit your Pi settings file:
nano ~/.pi/agent/settings.jsonAdd these two lines:
{
"defaultProvider": "openrouter",
"defaultModel": "openrouter/free",
...
}That’s it. The openrouter/free router automatically picks the best available free model each time you chat.
What “Free” Actually Means
- No token charges — ever
- Rate limits: 50 requests/day without credits, 1,000/day if you add $10+ in credits
- Models: Llama 3.3 70B, Qwen3 Coder, GPT-OSS 120B, Nemotron 3 Super
The free router picks whichever model is cheapest and least congested at request time.
Why I Like This
| Benefit | Details |
|---|---|
| Zero cost | Never pay per token |
| Automatic routing | No model picking needed |
| Easy toggle | Remove defaultModel to go back to Ollama |
Gotchas
- API key required — OpenRouter still needs a key even for free models
- Credit balance — You need some credit balance to activate your key, even for free models
- Rate limits — Hit the daily cap? Either wait or add credits for higher limits
Quick Troubleshooting
“Insufficient credits” error?
Your key is valid but your account never bought credits. Go to https://openrouter.ai/settings/credits and add $10 to unlock the higher free-tier limits.
Want to switch back to Ollama?
Remove defaultModel from settings.json or set it to an Ollama model ID.
Need more throughput?
Add $10 in credits at openrouter.ai/settings/credits. That bumps you from 50→1,000 free requests/day.
The CLI Way
If you’re scripting or want to override:
pi --provider openrouter --model openrouter/freeOr pick a specific free model:
pi --provider openrouter --model qwen/qwen3-coder:freeThat’s It
Point Pi at openrouter/free, add a key, done. No token costs, automatic model selection, and you can still swap providers anytime.