OpenRouter provider extension for Pi Coding Agent - access 20+ LLM models through unified API
npm install @verioussmith/pi-openrouter

OpenRouter provider extension for Pi Coding Agent.
- 🚀 Access 20+ LLM models through OpenRouter's unified API
- 🔄 OpenAI-compatible streaming
- 🤖 Supports Claude, GPT-4, Gemini, Llama, Mistral, DeepSeek, Perplexity
- 🆓 Free models available (Gemini 2.0 Flash)
- 📦 One-command installation via npm
- âš¡ Auto-installs to ~/.pi/agent/extensions/
``bash`
npm install -g @verioussmith/pi-openrouter
That's it! The extension automatically installs to ~/.pi/agent/extensions/openrouter.ts
See INSTALL.md for manual installation options.
Set your OpenRouter API key in ~/.zshrc or environment:
`bash`
export OPENROUTER_API_KEY="sk-or-v1-YOUR_KEY_HERE"
Get your key at: https://openrouter.ai/settings/keys
`bashStart pi
pi
Available Models
$3
- google/gemini-2.0-flash-exp:free - Gemini 2.0 Flash Experimental
- google/gemini-2.0-flash-thinking-exp:free - Gemini 2.0 Flash with reasoning$3
- anthropic/claude-3.5-sonnet - Claude 3.5 Sonnet
- anthropic/claude-3-opus - Claude 3 Opus
- anthropic/claude-3-haiku - Claude 3 Haiku$3
- openai/gpt-4o - GPT-4o
- openai/gpt-4o-mini - GPT-4o Mini
- openai/o1 - O1 (reasoning model)
- openai/o1-mini - O1 Mini$3
- google/gemini-pro-1.5 - Gemini Pro 1.5$3
- meta-llama/llama-3.3-70b-instruct - Llama 3.3 70B
- meta-llama/llama-3.1-405b-instruct - Llama 3.1 405B$3
- mistralai/mistral-large - Mistral Large
- mistralai/mistral-small - Mistral Small$3
- deepseek/deepseek-chat - DeepSeek Chat
- deepseek/deepseek-r1 - DeepSeek R1 (reasoning)$3
- perplexity/sonar-pro - Sonar ProSee all models: https://openrouter.ai/models
Adding More Models
Edit
openrouter.ts and add to the models array:`typescript
{
id: "provider/model-name",
name: "Display Name (OpenRouter)",
reasoning: false, // true for reasoning models
input: ["text", "image"], // or just ["text"]
cost: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0 },
contextWindow: 128000,
maxTokens: 4096,
}
`Costs are in $/million tokens. Check https://openrouter.ai/models for pricing.
Development
`bash
Clone
git clone https://github.com/verioussmith/pi-openrouter-extension.git
cd pi-openrouter-extensionInstall in Pi (development mode)
ln -s $(pwd)/openrouter.ts ~/.pi/agent/extensions/openrouter.tsTest
pi
/model openrouter/google/gemini-2.0-flash-exp:free
`$3
`bash
Update version in package.json
npm version patch # or minor, majorCommit and push
git add . && git commit -m "chore: bump version" && git pushPublish to npm (requires OTP)
npm publish --access public --otp=YOUR_OTP
``- npm: https://www.npmjs.com/package/@verioussmith/pi-openrouter
- GitHub: https://github.com/verioussmith/pi-openrouter-extension
- Issues: https://github.com/verioussmith/pi-openrouter-extension/issues
- Pi Coding Agent
- Pi Custom Provider Docs
- OpenRouter API
- OpenRouter Models
Contributions welcome! Please:
1. Fork the repo
2. Create a feature branch
3. Submit a pull request
Verious Smith (@verioussmith)
- Website: https://philoveracity.com
- Email: verious@philoveracity.com
MIT - see LICENSE file for details