Skip to content

Commit 79a530f

Browse files
Feat/perplexity plugin (#138)
* feat: add Perplexity plugin with usage analytics and local cache support * feat: enhance SQLite for dbs using CFNetwork cache * feat: handle unavailable usage analytics in plugin and add corresponding test * fix: correct brand color in plugin.json and update icon.svg fill color --------- Co-authored-by: Robin Ebers <robin.ebers@gmail.com>
1 parent e4bdae2 commit 79a530f

6 files changed

Lines changed: 663 additions & 7 deletions

File tree

docs/providers/perplexity.md

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
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).

plugins/perplexity/icon.svg

Lines changed: 1 addition & 0 deletions
Loading

0 commit comments

Comments
 (0)