|
| 1 | +# Perplexity |
| 2 | + |
| 3 | +> Uses Perplexity macOS app session data from local cache (no manual configuration). |
| 4 | +
|
| 5 | +## Overview |
| 6 | + |
| 7 | +- **Protocol:** HTTPS (JSON) |
| 8 | +- **Auth:** Bearer token extracted from local Perplexity app cache request object |
| 9 | +- **Data sources:** |
| 10 | + - `Cache.db` (local CFNetwork cache) for token + app headers |
| 11 | + - REST API for balance + usage analytics |
| 12 | + |
| 13 | +## Local Session (Required) |
| 14 | + |
| 15 | +1. Install the Perplexity macOS app. |
| 16 | +2. Open the app and sign in once. |
| 17 | + |
| 18 | +The plugin checks for the Perplexity cache DB at: |
| 19 | + |
| 20 | +- `~/Library/Containers/ai.perplexity.mac/Data/Library/Caches/ai.perplexity.mac/Cache.db` |
| 21 | +- fallback: `~/Library/Caches/ai.perplexity.mac/Cache.db` |
| 22 | + |
| 23 | +It reads the cached request object for: |
| 24 | + |
| 25 | +- `https://www.perplexity.ai/api/user` |
| 26 | + |
| 27 | +Then extracts the cached request's `Authorization: Bearer ...` token (and app-like headers). |
| 28 | + |
| 29 | +If no local session is found, the plugin throws: |
| 30 | + |
| 31 | +- `Not logged in. Sign in via Perplexity app.` |
| 32 | + |
| 33 | +## Balance + Usage (No Env Vars) |
| 34 | + |
| 35 | +When a bearer token is present in the cache DB, the plugin calls: |
| 36 | + |
| 37 | +- `GET https://www.perplexity.ai/rest/pplx-api/v2/groups` (resolve `<api_org_id>`) |
| 38 | +- `GET https://www.perplexity.ai/rest/pplx-api/v2/groups/<api_org_id>` (read `customerInfo.balance`) |
| 39 | +- `GET https://www.perplexity.ai/rest/pplx-api/v2/groups/<api_org_id>/usage-analytics` (sum `cost`) |
| 40 | + |
| 41 | +## Output |
| 42 | + |
| 43 | +- **Plan**: `Pro` when `customerInfo.is_pro === true` |
| 44 | +- **Usage** (single progress bar line): |
| 45 | + - `limit = customerInfo.balance` |
| 46 | + - `used = sum(usage-analytics[].meter_event_summaries[].cost)` |
| 47 | + - `resetsAt` not set (UI shows `$<limit> limit`, no reset countdown) |
| 48 | + |
| 49 | +## Limitations |
| 50 | + |
| 51 | +- Cache format is app-version dependent and may change. |
| 52 | +- The REST endpoints used are not a public usage API (may change or break without notice). |
| 53 | +- Some REST endpoints may be protected by Cloudflare; the plugin sends app-like headers from the cached request object, but may still be blocked (usage will be unavailable). |
0 commit comments