| name | perplexity-architecture-variants |
| description | Choose and implement Perplexity architecture blueprints for different scales:
direct search widget, cached research layer, and multi-query pipeline.
Trigger with phrases like "perplexity architecture", "perplexity blueprint",
"how to structure perplexity", "perplexity project layout".
|
| allowed-tools | Read, Grep |
| version | 1.12.0 |
| license | MIT |
| author | Jeremy Longshore <jeremy@intentsolutions.io> |
| tags | ["saas","perplexity","migration","scaling","microservices"] |
| compatibility | Designed for Claude Code, also compatible with Codex and OpenClaw |
Perplexity Architecture Variants
Overview
Three validated architectures for Perplexity Sonar API at different scales. Each builds on the previous, adding caching and orchestration as volume grows.
Decision Matrix
| Factor | Direct Widget | Cached Layer | Research Pipeline |
|---|
| Volume | <500/day | 500-5K/day | 5K+/day |
| Latency (p50) | 2-5s | 50ms (cached) / 2-5s (miss) | 10-30s |
| Model | sonar | sonar + cache | sonar + sonar-pro |
| Monthly Cost | <$150 | $50-$300 | $300+ |
| Complexity | Minimal | Moderate | High |
Instructions
Variant 1: Direct Search Widget (<500 queries/day)
Best for: Adding AI search to an existing app. No cache needed at this scale.
import OpenAI from "openai";
const perplexity = new OpenAI({
apiKey: process.env.PERPLEXITY_API_KEY!,
baseURL: "https://api.perplexity.ai",
});
app.post("/api/search", async (req, res) => {
try {
const response = await perplexity.chat.completions.create({
model: "sonar",
messages: [{ role: , : req.. }],
: ,
});
res.({
: response.[]..,
: (response ). || [],
});
} (: ) {
(err. === ) {
res.().({ : });
} {
res.().({ : });
}
}
});