README.md

 1# Zed Perplexity Extension
 2
 3This example extension adds the `/perplexity` [slash command](https://zed.dev/docs/assistant/commands) to the Zed AI assistant.
 4
 5## Usage
 6
 7Open the AI Assistant panel (`cmd-r` or `ctrl-r`) and enter:
 8
 9```
10/perplexity What's the weather in Boulder, CO tomorrow evening?
11```
12
13## Development Setup
14
151. Install the Rust toolchain and clone the zed repo:
16
17   ```
18   curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
19
20   mkdir -p ~/code
21   cd ~/code
22   git clone https://github.com/zed-industries/zed
23   ```
24
251. Open Zed
261. Open Zed Extensions (`cmd-shift-x` / `ctrl-shift-x`)
271. Click "Install Dev Extension"
281. Navigate to the "extensions/perplexity" folder inside the zed git repo.
291. Ensure your `PERPLEXITY_API_KEY` environment variable is set (instructions below)
30
31   ```sh
32   env | grep PERPLEXITY_API_KEY
33   ```
34
351. Quit and relaunch Zed
36
37## PERPLEXITY_API_KEY
38
39This extension requires a Perplexity API key to be available via the `PERPLEXITY_API_KEY` environment variable.
40
41To obtain a Perplexity.ai API token, login to your Perplexity.ai account and go [Settings->API](https://www.perplexity.ai/settings/api) and under "API Keys" click "Generate". This will require you to have [Perplexity Pro](https://www.perplexity.ai/pro) or to buy API credits. By default the extension uses `llama-3.1-sonar-small-128k-online`, currently cheapest model available which is roughly half a penny per request + a penny per 50,000 tokens. So most requests will cost less than $0.01 USD.
42
43Take your API key and add it to your environment by adding `export PERPLEXITY_API_KEY="pplx-0123456789abcdef..."` to your `~/.zshrc` or `~/.bashrc`. Reload close and reopen your terminal session. Check with `env |grep PERPLEXITY_API_KEY`.