This example extension adds the /perplexity slash command to the Zed AI assistant.
Open the AI Assistant panel (cmd-r or ctrl-r) and enter:
/perplexity What's the weather in Boulder, CO tomorrow evening?
-
Install the Rust toolchain and clone the zed repo:
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh mkdir -p ~/code cd ~/code git clone https://github.com/zed-industries/zed -
Open Zed
-
Open Zed Extensions (
cmd-shift-x/ctrl-shift-x) -
Click "Install Dev Extension"
-
Navigate to the "extensions/perplexity" folder inside the zed git repo.
-
Ensure your
PERPLEXITY_API_KEYenvironment variable is set (instructions below)env | grep PERPLEXITY_API_KEY -
Quit and relaunch Zed
This extension requires a Perplexity API key to be available via the PERPLEXITY_API_KEY environment variable.
To obtain a Perplexity.ai API token, login to your Perplexity.ai account and go Settings->API and under "API Keys" click "Generate". This will require you to have Perplexity Pro or to buy API credits. By default the extension uses sonar, currently cheapest model available which is $0.008 per request (less than a penny) + a penny per 10,000 tokens. So most requests will cost $0.01 - $0.02 USD.
Take 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.