feat(ai): add OpenRouter OAuth support (#6927)

Closes #6814
This commit is contained in:
Saryev Rustam
2026-07-22 16:48:39 +03:00
committed by GitHub
parent fe42ba5b38
commit 7b52cef2e6
9 changed files with 522 additions and 6 deletions
+8 -1
View File
@@ -20,9 +20,10 @@ Use `/login` in interactive mode, then select a provider:
- Claude Pro/Max
- GitHub Copilot
- xAI (Grok/X subscription)
- OpenRouter (OAuth-minted API key billed from OpenRouter credits)
- Radius
Use `/logout` to clear credentials. Tokens are stored in `~/.pi/agent/auth.json` and auto-refresh when expired.
Use `/logout` to clear credentials. Tokens are stored in `~/.pi/agent/auth.json` and auto-refresh when expired. OpenRouter instead mints a user-controlled API key that does not expire automatically.
### OpenAI Codex
@@ -43,6 +44,12 @@ Anthropic subscription auth is active for Claude Pro/Max accounts. Third-party h
- Run `/login xai`, then select **Use a subscription**
- `XAI_API_KEY` remains available through **Use an API key**
### OpenRouter
- Run `/login openrouter`, then select **Sign in with OpenRouter** to open the OpenRouter PKCE authorization flow
- The authorization creates a user-controlled OpenRouter API key billed from your OpenRouter credits
- `OPENROUTER_API_KEY` remains available through **Use an API key**
### Radius
Radius is a dynamic `pi-messages` gateway. `/login radius` stores OAuth tokens in `auth.json`; the gateway catalog is refreshed independently and cached in `models-store.json`. Custom Radius gateways can be declared in `models.json` with `"oauth": "radius"` and a gateway `baseUrl`.