| name | perplexity-security-basics |
| description | Apply Perplexity security best practices for API key management and query safety.
Use when securing API keys, implementing query sanitization,
or auditing Perplexity security configuration.
Trigger with phrases like "perplexity security", "perplexity secrets",
"secure perplexity", "perplexity API key security", "perplexity PII".
|
| allowed-tools | Read, Write, Grep |
| version | 1.12.0 |
| license | MIT |
| author | Jeremy Longshore <jeremy@intentsolutions.io> |
| tags | ["saas","perplexity","api","security","audit"] |
| compatibility | Designed for Claude Code, also compatible with Codex and OpenClaw |
Perplexity Security Basics
Overview
Security best practices for Perplexity Sonar API. Key concerns: API key protection (keys start with pplx-), query sanitization (Perplexity searches the open web, so PII in queries gets sent to external sources), and response handling (citations link to third-party sites).
Prerequisites
- Perplexity API key from perplexity.ai/settings/api
- Understanding of environment variable management
.gitignore configured to exclude secret files
Instructions
Step 1: API Key Management
PERPLEXITY_API_KEY=pplx-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
.env
.env.local
.env.*.local
*.pem
function validateApiKey(key: string): void {
if (!key) throw new Error("PERPLEXITY_API_KEY is not set");
if (!key.startsWith("pplx-")) {
throw new Error("PERPLEXITY_API_KEY must start with 'pplx-'");
}
if (key.length < 40) {
throw new Error("PERPLEXITY_API_KEY appears truncated");
}
}
validateApiKey(process.env.PERPLEXITY_API_KEY || "");