OpenParable
Skip to content
← Back to skills

Perplexity Install Auth

Apps & Automation
perplexity-install-auth

Perplexity Install Auth is an Agent Skill for apps & automation published in the jeremylongshore/claude-code-plugins-plus-skills repository on GitHub: a SKILL.md instruction file an AI agent can load to do this task.

Install and configure Perplexity Sonar API authentication. Use when setting up a new Perplexity integration, configuring API keys, or initializing the OpenAI-compatible client for Perplexity. Trigger with phrases like "install perplexity", "setup perplexity", "perplexity auth", "configure perplexity API key", "perplexity sonar setup".

View on GitHub ↗
QUICK START

How to use this skill

Bring this guide into your coding agent with a prompt tailored to the tool you use.

  1. Open your project in Codex.
  2. Copy and paste the prompt below.
  3. Review files and risks before approving any action.
Prompt to paste
Inspect the Agent Skill at https://github.com/jeremylongshore/claude-code-plugins-plus-skills/blob/HEAD/plugins/saas-packs/perplexity-pack/skills/perplexity-install-auth/SKILL.md and all supporting files. Report provenance, permissions, scripts, dependencies, and security risks. Propose an exact installation into .agents/skills/perplexity-install-auth, but wait for my approval before writing files or running scripts.

Copying this prompt does not install or run the skill. Review third-party files before use.

Perplexity Install & Auth

Overview

Set up Perplexity Sonar API access using the OpenAI-compatible chat completions endpoint at https://api.perplexity.ai. Perplexity does not have a custom SDK -- you use the standard OpenAI client library pointed at Perplexity's base URL.

Prerequisites

Instructions

Step 1: Install OpenAI Client Library

set -euo pipefail
# Node.js / TypeScript
npm install openai

# Python
pip install openai

There is no @perplexity/sdk package. Perplexity uses the OpenAI wire format, so you use the official openai package with a custom baseURL.

Step 2: Configure API Key

# Set environment variable
export PERPLEXITY_API_KEY="pplx-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"

# Or create .env file (add .env to .gitignore)
echo 'PERPLEXITY_API_KEY=pplx-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx' >> .env

API keys start with pplx- and are generated at perplexity.ai/settings/api. You must add credits to your account before making API calls.

Step 3: Verify Connection (TypeScript)

import OpenAI from "openai";

const client = new OpenAI({
  apiKey: process.env.PERPLEXITY_API_KEY,
  baseURL: "https://api.perplexity.ai",
});

async function verify() {
  const response = await client.chat.completions.create({
    model: "sonar",
    messages: [{ role: "user", content: "What is 2+2?" }],
    max_tokens: 50,
  });
  console.log("Connected:", response.choices[0].message.content);
  console.log("Model:", response.model);
  console.log("Tokens used:", response.usage?.total_tokens);
}

verify().catch(console.error);

Step 4: Verify Connection (Python)

import os
from openai import OpenAI

client = OpenAI(
    api_key=os.environ["PERPLEXITY_API_KEY"],
    base_url="https://api.perplexity.ai",
)

response = client.chat.completions.create(
    model="sonar",
    messages=[{"role": "user", "content": "What is 2+2?"}],
    max_tokens=50,
)
print("Connected:", response.choices[0].message.content)
print("Model:", response.model)
print("Tokens:", response.usage.total_tokens)

Available Models

ModelUse CaseInput $/M tokensOutput $/M tokens
sonarFast search, simple queries$1$1
sonar-proDeep research, more citations$3$15
sonar-reasoning-proChain-of-thought with search$3$15
sonar-deep-researchMulti-step research synthesis$2$8

Error Handling

ErrorCauseSolution
401 UnauthorizedInvalid or missing API keyVerify key starts with pplx- and has credits
403 ForbiddenKey lacks model accessCheck key permissions at perplexity.ai/settings
Module not found: openaiSDK not installedRun npm install openai or pip install openai
Connection refusedWrong base URLEnsure baseURL is https://api.perplexity.ai

Output

  • OpenAI client configured with Perplexity base URL
  • Successful API response confirming connection
  • Token usage confirming billing is active

Resources

Next Steps

After successful auth, proceed to perplexity-hello-world for your first search query.