pi-provider-litellm
v1.2.2
Published
LiteLLM proxy provider extension for Pi
Maintainers
Readme
pi-provider-litellm
LiteLLM proxy provider extension for Pi.
Discovers models from a self-hosted LiteLLM proxy and registers them under the litellm provider. Supports /login litellm and /litellm-refresh. Tries /model/info first (admin endpoint with rich metadata), falls back to /v1/models (OpenAI-compatible) on 401/403/404.
Install
pi install npm:pi-provider-litellmPi fetches the package from npm and registers it. Add -l to install into project settings (.pi/settings.json) instead of global.
To try it without installing (one-off, current run only):
pi -e npm:pi-provider-litellmgit clone https://github.com/balcsida/pi-provider-litellm.git ~/.pi/agent/extensions/pi-provider-litellm
cd ~/.pi/agent/extensions/pi-provider-litellm
npm install
npm run buildConfigure
Option A — interactive login
Inside pi:
/login litellmYou'll be prompted for the base URL and API key. Credentials are persisted to ~/.pi/agent/auth.json.
Option B — environment variables
export LITELLM_BASE_URL="https://litellm.your-domain.com"
export LITELLM_API_KEY="sk-..."Stored pi credentials for litellm take precedence over LITELLM_API_KEY; the environment key is used when no saved credential exists. LITELLM_BASE_URL is used when no saved login base URL exists.
Use
/modelOptional environment variables
| Variable | Default | Effect |
|---|---|---|
| LITELLM_OFFLINE | unset | If 1, skip discovery on this start; use cache only |
| LITELLM_DISCOVERY_TIMEOUT_MS | 5000 | Discovery fetch timeout in ms; 0 to skip discovery |
LITELLM_DISCOVERY_TIMEOUT_MS=0 only disables startup and refresh model discovery. It does not replace the base URL or API key settings required to send requests when you are not using /login litellm.
Slash commands
/litellm-refresh— force re-fetch the model list, ignoring cache
Cache
The model list is cached at ~/.pi/agent/litellm-models.json with a keyed fingerprint of the base URL + API key. Changing either invalidates the cache automatically.
Troubleshooting
| Symptom | Likely cause |
|---|---|
| "no credentials" warning at startup | Env vars not set and no OAuth credential — run /login litellm |
| "discovered no models" | Proxy returned an empty list — check pi's startup log for the actual response |
| /model/info returning 401/403/404 | Expected behavior with virtual keys — extension falls back to /v1/models |
| Discovery times out | Increase LITELLM_DISCOVERY_TIMEOUT_MS or set LITELLM_OFFLINE=1 to fall back on cached models |
License
MIT — see LICENSE.
