# @openference/pi-provider

Official [Openference](https://openference.com) provider for [Pi](https://pi.dev).

Signs in with the same Openference OAuth device flow used by first-party apps: Pi prints a link you click or copy into a browser, you approve, and models load automatically with correct context windows, pricing, and plan-aware request pacing.

## Install

```bash
pi install npm:@openference/pi-provider
```

Restart Pi, then:

```text
/login openference
/model openference/GLM-5.2
```

Choose **Browser link** when prompted. Open the printed URL, sign in to Openference if needed, and approve. Pi stores tokens in `~/.pi/agent/auth.json`.

You can also paste an API key (secondary option) or set `OPENFERENCE_API_KEY`.

## What this package configures

- Live model list from `GET /v1/models` (respects your key’s model restrictions; run `/reload` after changes)
- Safe context windows and max output tokens so Pi compacts at the right time
- Thinking / reasoning levels from each model’s supported efforts
- Soft pacing from your plan’s RPM limit, and correct handling of `Retry-After` on rate limits
- Automatic recovery when a prompt exceeds the model context

If you keep hitting plan limits, [upgrade or add credits](https://openference.com/dashboard) — the package already respects your allowance.

## References

- [Pi guide](https://openference.com/docs/pi)
- [API reference](https://docs.openference.com/api-reference)
- [Models](https://openference.com/models)
