perplexity-multi-env-setup
Configure Perplexity Sonar API across development, staging, and production environments. Use when setting up multi-environment search integrations, managing API keys per environment, or controlling cost through model routing by env. Trigger with phrases like "perplexity environments", "perplexity staging", "perplexity dev prod", "perplexity environment config".
What this skill does
# Perplexity Multi-Environment Setup
## Overview
Configure Perplexity Sonar API across dev/staging/prod. Key decisions per environment: which models are allowed (sonar vs sonar-pro), rate limits, and cost caps. All environments use the same base URL (`https://api.perplexity.ai`) but different API keys with different budget limits.
## Environment Strategy
| Environment | Model | Rate Limit | Key Source | Monthly Budget |
|-------------|-------|-----------|------------|----------------|
| Development | `sonar` only | 5 RPM self-imposed | `.env.local` | $10 |
| Staging | `sonar` only | 20 RPM | CI secrets | $50 |
| Production | `sonar` + `sonar-pro` | 50 RPM | Secret manager | $500+ |
## Prerequisites
- Separate Perplexity API keys per environment
- `openai` package installed
- Secret management (env files for dev, vault/KMS for prod)
## Instructions
### Step 1: Configuration Structure
```
config/
perplexity/
base.ts # OpenAI client + base URL
development.ts # Dev: sonar only, low limits
staging.ts # Staging: sonar only, moderate limits
production.ts # Prod: full model access
index.ts # Environment resolver
```
### Step 2: Base Configuration
```typescript
// config/perplexity/base.ts
import OpenAI from "openai";
export const PERPLEXITY_BASE_URL = "https://api.perplexity.ai";
export function createPerplexityClient(apiKey: string): OpenAI {
if (!apiKey) throw new Error("Perplexity API key is required");
if (!apiKey.startsWith("pplx-")) throw new Error("Invalid Perplexity API key format");
return new OpenAI({ apiKey, baseURL: PERPLEXITY_BASE_URL });
}
```
### Step 3: Environment Configs
```typescript
// config/perplexity/development.ts
export const devConfig = {
apiKey: process.env.PERPLEXITY_API_KEY!,
defaultModel: "sonar" as const,
deepModel: "sonar" as const, // No sonar-pro in dev (cost)
maxTokens: 512,
maxConcurrentRequests: 1,
cacheTTLMs: 24 * 3600_000, // Long cache in dev
};
// config/perplexity/staging.ts
export const stagingConfig = {
apiKey: process.env.PERPLEXITY_API_KEY_STAGING!,
defaultModel: "sonar" as const,
deepModel: "sonar" as const, // Keep sonar in staging
maxTokens: 1024,
maxConcurrentRequests: 2,
cacheTTLMs: 4 * 3600_000,
};
// config/perplexity/production.ts
export const productionConfig = {
apiKey: process.env.PERPLEXITY_API_KEY_PROD!,
defaultModel: "sonar" as const, // Fast queries use sonar
deepModel: "sonar-pro" as const, // Research queries use sonar-pro
maxTokens: 4096,
maxConcurrentRequests: 10,
cacheTTLMs: 1 * 3600_000, // Shorter cache in prod (freshness)
};
```
### Step 4: Environment Resolver
```typescript
// config/perplexity/index.ts
import { createPerplexityClient } from "./base";
import { devConfig } from "./development";
import { stagingConfig } from "./staging";
import { productionConfig } from "./production";
type SearchDepth = "quick" | "deep";
const configs = {
development: devConfig,
staging: stagingConfig,
production: productionConfig,
};
export function getConfig() {
const env = process.env.NODE_ENV || "development";
const config = configs[env as keyof typeof configs];
if (!config) throw new Error(`Unknown environment: ${env}`);
if (!config.apiKey) throw new Error(`PERPLEXITY_API_KEY not set for ${env}`);
return config;
}
export function getClient() {
return createPerplexityClient(getConfig().apiKey);
}
export function getModelForDepth(depth: SearchDepth): string {
const cfg = getConfig();
return depth === "deep" ? cfg.deepModel : cfg.defaultModel;
}
```
### Step 5: Usage with Environment-Aware Search
```typescript
// lib/search.ts
import { getClient, getModelForDepth, getConfig } from "../config/perplexity";
export async function search(query: string, depth: "quick" | "deep" = "quick") {
const client = getClient();
const model = getModelForDepth(depth);
const config = getConfig();
const result = await client.chat.completions.create({
model,
messages: [
{ role: "system", content: "Provide accurate, well-sourced answers." },
{ role: "user", content: query },
],
max_tokens: depth === "deep" ? config.maxTokens : Math.min(512, config.maxTokens),
});
return {
answer: result.choices[0].message.content,
citations: (result as any).citations || [],
model,
environment: process.env.NODE_ENV,
usage: result.usage,
};
}
```
### Step 6: Secret Manager Integration (Production)
```bash
set -euo pipefail
# Google Cloud Secret Manager
gcloud secrets create perplexity-api-key-prod \
--data-file=<(echo -n "$PERPLEXITY_API_KEY_PROD")
# AWS Secrets Manager
aws secretsmanager create-secret \
--name perplexity/api-key-prod \
--secret-string "$PERPLEXITY_API_KEY_PROD"
# HashiCorp Vault
vault kv put secret/perplexity api_key="$PERPLEXITY_API_KEY_PROD"
```
## Error Handling
| Issue | Cause | Solution |
|-------|-------|----------|
| `401` in staging | Wrong API key for environment | Verify `PERPLEXITY_API_KEY_STAGING` |
| `429` in dev | Exceeding self-imposed limit | Add request queuing |
| sonar-pro in dev | Config not restricting models | Set `deepModel: "sonar"` in dev config |
| High dev costs | Using production config locally | Ensure `NODE_ENV=development` is set |
## Output
- Environment-specific Perplexity configurations
- Model routing by environment and query depth
- Secret manager integration for production keys
- Cost controls per environment
## Resources
- [Perplexity API Documentation](https://docs.perplexity.ai)
- [Perplexity Pricing](https://docs.perplexity.ai/docs/getting-started/pricing)
## Next Steps
For deployment configuration, see `perplexity-deploy-integration`.
Related in Backend & APIs
jfrog
IncludedInteract with the JFrog Platform via the JFrog CLI and REST/GraphQL APIs. Use this skill when the user wants to manage Artifactory repositories, upload or download artifacts, manage builds, configure permissions, manage users and groups, work with access tokens, configure JFrog CLI servers, search artifacts, manage properties, set up replication, manage JFrog Projects, run security audits or scans, look up CVE details, query exposures scan results from JFrog Advanced Security, manage release bundles and lifecycle operations, aggregate or export platform data, or perform any JFrog Platform administration task. Also use when the user mentions jf, jfrog, artifactory, xray, distribution, evidence, apptrust, onemodel, graphql, workers, mission control, curation, advanced security, exposures, or any JFrog product name.
cupynumeric-migration-readiness
IncludedPre-migration readiness assessor for porting NumPy to cuPyNumeric. Use BEFORE substantial porting work begins when the user asks whether code will scale on GPU, whether they should migrate to cuPyNumeric, which NumPy patterns transfer cleanly, what must be refactored before porting, or mentions pre-port assessment, scaling analysis, or refactor planning. Inspect the user's source code, look up NumPy usage, cross-reference the cuPyNumeric API support manifest, and distinguish distributed-scaling-friendly patterns from blockers such as unsupported APIs, scalar synchronization, host round-trips, Python/object-heavy control flow, shape/data-dependent branching, and in-place mutation hazards. Produce a verdict of READY, LIGHT REFACTOR, SIGNIFICANT REFACTOR, or NOT RECOMMENDED, with concrete refactor pointers.
alibabacloud-data-agent-skill
IncludedInvoke Alibaba Cloud Apsara Data Agent for Analytics via CLI to perform natural language-driven data analysis on enterprise databases. Data Agent for Analytics is an intelligent data analysis agent developed by Alibaba Cloud Database team for enterprise users. It automatically completes requirement analysis, data understanding, analysis insights, and report generation based on natural language descriptions. This tool supports: discovering data resources (instances/databases/tables) managed in DMS, initiating query or deep analysis sessions, real-time progress tracking, and retrieving analysis conclusions and generated reports. Use this Skill when users need to query databases, analyze data trends, generate data reports, ask questions in natural language, or mention "Data Agent", "data analysis", "database query", "SQL analysis", "data insights".
token-optimizer
IncludedReduce OpenClaw token usage and API costs through smart model routing, heartbeat optimization, budget tracking, and native 2026.2.15 features (session pruning, bootstrap size limits, cache TTL alignment). Use when token costs are high, API rate limits are being hit, or hosting multiple agents at scale. The 4 executable scripts (context_optimizer, model_router, heartbeat_optimizer, token_tracker) are local-only — no network requests, no subprocess calls, no system modifications. Reference files (PROVIDERS.md, config-patches.json) document optional multi-provider strategies that require external API keys and network access if you choose to use them. See SECURITY.md for full breakdown.
resend-cli
IncludedUse this skill when the task is specifically about operating Resend from an AI agent, terminal session, or CI job via the official resend CLI: installing/authenticating the CLI, sending/listing/updating/cancelling emails, batch sends, domains and DNS, webhooks and local listeners, inbound receiving, contacts, topics, segments, broadcasts, templates, API keys, profiles, or debugging Resend CLI/API failures. Trigger on mentions of Resend CLI, `resend`, `resend doctor`, `resend emails send`, `resend domains`, `resend webhooks listen`, `resend emails receiving`, or agent-friendly terminal automation.
alibabacloud-odps-maxframe-coding
IncludedUse this skill for MaxFrame SDK development and documentation navigation on Alibaba Cloud MaxCompute (ODPS). Helps answer MaxFrame API, concept, official example, and supported pandas API questions; create data processing programs; read/write MaxCompute tables; debug jobs (remote or local); and build custom DPE runtime images. Trigger when users mention MaxFrame, MaxCompute with MaxFrame, ODPS table processing, DPE runtime, MaxFrame docs/examples, DataFrame/Tensor operations, or GPU runtime setup. Works for both English and Chinese queries about Alibaba Cloud data processing with MaxFrame.